GPIO: too easy to be hard

I am an experienced programmer and am rather embarrassed to ask what should be obvious. But for non-obvious reasons I am having a fundamental problem with simple I/O.

Starting with the example_blink_led app, I added a line to toggle a different I/O pin.

That did not work. Supposing the port was assigned wrong, I added

at the top of Main(). No go! So, since the red LED blinks fine in the example I commented it out and changed my pin to:

Still no blinky lights.

I have tried every combination of the GPIO functions including setting a port to static 1 without any success. What am I missing?

Hello,

“P1_0” and “P2_1” are actually registers defined in cc2511_map.h. If you are using the functions in the GPIO library, you should be passing in pin numbers as parameters instead (10 and 21), as explained in the SDK documentation under “The pinNumber parameter”:

setDigitalOutput(10, !isPinHigh(10));

Alternatively, if you actually want to work with the registers directly, you should be able to do something like this:

P1_0 = !P1_0;

- Kevin

Kevin,

Got it! I knew I was missing something fundamental. It all makes sense when I re-read the documentation. In my head I thought P1_0, etc were #defined to the pin numbers 10, etc. or were converted in the function. I even wrote that into my own reference material. Now I am really curious how I came to that conclusion other than it made logical sense in my way of thinking.

Thanks for the info. I will try it tonight and should be able to get on with my programming life. :smiley:

-Jeff