Go Down

Topic: Portenta H7 LED's HIGH means off? (Read 169 times) previous topic - next topic

jerteach

Jul 11, 2020, 07:29 am Last Edit: Jul 13, 2020, 04:21 pm by jerteach
This feels like a really stupid question but on the Portenta H7 does

false, 0, LOW mean LED on and
true, 1, HIGH mean LED off?


That is the results I am getting with this code:

Code: [Select]

void setup() {
   pinMode(LEDG, OUTPUT);   
}

void loop() {
   digitalWrite(LEDG, LOW);   
   delay(400);                     
   digitalWrite(LEDG, HIGH);   
   delay(4000);                     
}





See image below. The LED briefly flashes on and then is off for 4 seconds.




Can anyone explain this?

.


Note: If I change the pin to "9" and hook up a physical LED then everything works as expected, must be something specific to the builtin led's. Does anyone have the official explanation?





jerteach

#1
Jul 14, 2020, 02:53 am Last Edit: Jul 14, 2020, 03:04 am by jerteach
So please correct me if I am wrong but it looks like the onboard LED's (LEDR, LEDG, LEDB, LED_BUILTIN) are directly connected to 3V3, so to turn them on you need to connect them to ground which would be digitalWrite(LEDG, LOW). Very weird but if it is fixed in hardware so we are stuck with it (Probably some really good reason to do it this way).


The only correction would be if someone programs a little "if statement" to test for the use of the on board LED's and reverse the effect. (I would look into that if someone can point me to the appropriate github file)





tjaekel

Sure, schematic shows, that LED is connected on 3V3 rail, so it needs a drain, a low on the MCU pin (tie LED to GND).
Bear in mind, that this 'digitalWrite()' is not related to LEDs - it is for any MCU pin (drive it low or drive it high).

Maybe, the mbed OS, the HAL, has a function as setLed(On | Off) which can take take about how to set low or high for ON or OFF.
But here, the function used - is not related to and not specific to LEDs. It is just how to drive an MCU pin (and it must be low for ON, high for OFF - related to the schematics, in terms of LEDs).

Go Up