The board.h file in the led_blinky SDK example for the LPC824 uses 'GPIO_PortClear' to turn an output port HIGH, and 'GPIO_PortSet' to turn an output port LOW.
I have been trying to understand why 'clearing' results in a HIGH output (when it feels like it should result in LOW to me), but have not been able to find my answer in the processor manual. I know I am missing something, please could someone explain?
#define LED_RED_ON() \
GPIO_PortClear(BOARD_LED_RED_GPIO, BOARD_LED_RED_GPIO_PORT, \
1U << BOARD_LED_RED_GPIO_PIN)
#define LED_RED_OFF() \
GPIO_PortSet(BOARD_LED_RED_GPIO, BOARD_LED_RED_GPIO_PORT, \
1U << BOARD_LED_RED_GPIO_PIN)
Solved! Go to Solution.
Hi @scruffmeister,
This "inverted logic" is due to the physical connection of the LED on the LPCXpresso824MAX board:
The LEDs require anode to be high and the cathode to be low to turn ON.
In the schematic we can see that the anodes are already connected to 3.3V, while the cathodes are connected to the GPIO pins.
Therefore, if we set the GPIO pins to HIGH, there will be no potential difference between anode and cathode and the LED will remain OFF. If the GPIO are cleared to LOW, the potential difference will be present, and the LED will turn ON.
I hope this clears things up.
BR,
Edwin.
Hi @scruffmeister,
This "inverted logic" is due to the physical connection of the LED on the LPCXpresso824MAX board:
The LEDs require anode to be high and the cathode to be low to turn ON.
In the schematic we can see that the anodes are already connected to 3.3V, while the cathodes are connected to the GPIO pins.
Therefore, if we set the GPIO pins to HIGH, there will be no potential difference between anode and cathode and the LED will remain OFF. If the GPIO are cleared to LOW, the potential difference will be present, and the LED will turn ON.
I hope this clears things up.
BR,
Edwin.
Thank you, that makes perfect sense.