The simplest method of controlling an LED is to add a LED usermodule.
From the userdmodule window, expand "Misc Digital", and double click on "LED" to place it.
Use the "parameters" window to set a name to your LED and assign the pin and the active low/high logic. Press Ctrl+F6 to generate the usermodule files.
From your code, you can now use LEDname_On and LEDname_Off to switch your LED on and off (LEDname is the name you give to the usermodule)
If you perform read modify write operations on a port you need
to use shadow registers -
Forgot to add, if port has mixed I/O in it.
Using an LED usermodule automatically takes care of the Shadow register issue (if you want a quick intro to what shadow registers are all about, check out the second video on this page - http://www.cypress.com/?rID=2900)
But as per your post, if you want to avoid using a usermodule/shadow registers for some reason and use just the pin name, you can use the following code to control a pin-
led_Data_ADDR |= led_MASK;
led_Data_ADDR &= (~led_MASK);
// where "led" is the name you had given in the Pinout window, also check that Drive should be "Strong" for a digital output
The _Data_ADDR and _MASK are MACROS that are generated automatically, when you assign a name to a pin.
Note that advantage of this method is that you can also use for an input pin (configured as High-Z) for a read operation:
pinStatus = inputPin_Data_ADDR & inputPin_MASK;
Thanks for your replies, really appreciate it!
I have an LED on the output at them moment but the output may be used to send a signal to a transistor or otehr devices.
ill have a look through the links sent
thanks again guys
Using the Led user module even if you don't use mixed I/O on the port will save you a lot of trouble. I mean, if eventually you decide to have a pull-up on the next port pin, the shadow register will be automatically updated by using LedName_On(); or LedName_Off();. You won't need to care about read/modify/write issue.