Another Xc Question: Global Defs

Technical questions regarding the XTC tools and programming with XMOS.
mashc5
Member
Posts: 10
Joined: Sat May 29, 2010 6:06 am

Another Xc Question: Global Defs

Post by mashc5 »

I'm working on writing a graphic lcd library for an lcd that uses the typical 8-bit parallel interface. If I declare my ports globally, can I access them from functions like a normal global variable? For example...

Code: Select all

chan lcd_chan;

out port data_port = PORT_XS1_8A
port enable = PORT_XS1_1B
etc...

//Stuff happens in here that calls glcd_command
void glcd_thread(chanend c);

//Hardware Interface
void glcd_command(unsigned int cmd)
{
    //Assuming data_port hasn't been declared
    //out port data_port = PORT_XS1_8A <-------Is this ok at this level or does it need to be global?

    data_port <: cmd;

    //PORT_XS1_8A <: cmd       <------Is this ok? I'm assuming not or ports would have no purpose.
    
    enable <: 1;
    //Some Delay Here
    enable <: 0;
}
Thanks to everyone that responded to my last post! Like I said before, I'm getting my xc-1a in today so I'll probably be on here asking a lot of questions.

-Mark


User avatar
Jerry
Member++
Posts: 30
Joined: Sat Dec 12, 2009 7:14 pm
Location: Silicon Valley

Post by Jerry »

All ports must be declared as global variables per the following line from Programming XC on XMOS Devices:
All ports must be declared as global variables, and no two ports may be initialised
with the same port identifier.
Both of the lines in your code marked with "is this ok?" are not valid.