Content originally posted in LPCWare by NXP_USA on Tue May 11 14:17:35 MST 2010
Quote: dane.w.kim
Hello,
I'm still getting familiar with the part and am having some issues with the GPIO. I'm trying to toggle bits 4 through 7 on Port 2. I'm using the getters and setters as described in the examples.
It seems I'm able to toggle bit 6 and 7, but am unable to change bits 4 and 5. I have verified that the pins are configured to output. Just to verify that I'm not missing something (which, I guess this post means that I AM), I used the blinky exampled and tried changing the output pin to bits 4 through 7 on Port 2. Again, only 6 and 7 change, while 4 and 5 stay high.
Any assistance would be appreciated.
It sounds like this isn't the problem in your specific case, but in general, the default power-on-reset pin function should be checked in the User's Manual in the I/O configuration chapter. Some pins do not come configured as GPIO after reset and need to have their pin function set before they can be used as outputs.
If you are still developing code and using the debugger and reset pin, don't reconfigure SWDIO, SWCLK, and reset. Another tip is the gpio.c InitGPIO function will set up some of the pins as GPIO. Calling InitGPIO can interfere with some ADC pins, so if you have trouble with and ADC inputs make sure those pins are properly initialized. The pin functions can be checked live in the LPCXpresso Memory View after enabling the GPIO ports in the Peripherals view.