Another Xc Question: Global Defs

Technical questions regarding the xTIMEcomposer, xSOFTip Explorer and Programming with XMOS.
Posts: 10
Joined: Sat May 29, 2010 6:06 am

Another Xc Question: Global Defs

Postby mashc5 » Tue Jul 13, 2010 1:27 pm

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

//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.

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

Postby Jerry » Tue Jul 13, 2010 6:18 pm

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.

Who is online

Users browsing this forum: No registered users and 6 guests