This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

HAL_turnLedOn/Off are inverted

Other Parts Discussed in Thread: LAUNCHXL-F28069M

Hi,

I am using the LAUNCHXL-F28069M with InstaSPIN and just noticed a weird thing: When I call HAL_turnLedOn(), the specified LED turns off. When I call HAL_turnLedOff(), it turns on. That is, it behaves inverted to what is expected.

Looking at the function definitions, they are just

#define HAL_turnLedOff HAL_setGpioLow
#define HAL_turnLedOn HAL_setGpioHigh

I could not find a documentation for this, is it correct that the LEDs are turned on by setting the GPIOs low? If yes, I guess this is a bug in InstaSPIN (wrong defines of the LED-functions). If no: any idea where I could have messed it up so that it behaves in this counter-intuitive way?

Best, Felix

  • Hi Felix,

    Are you using the LEDs that are connected to GPIOs 34 and 39? I took a look at the LaunchPad schematic and it looks like they're in an active low configuration, so it makes sense that low=on and high=off.

    I suspect these defines were copied over some some controlCARD HAL code where the LED circuits are active high. I'll file a bug report. Thanks for reporting this.

    Whitney
  • Hi Whitney,

    thanks for verifying this. I am indeed using the LEDs connected to GPIOs 34 & 39.

    Best, Felix

  • Hi Felix,

    You are right. Refer to the schematic of LAUNCHXL-F28069M, should use "HAL_setGpioLow()" to turn on LED, and use "HAL_setGpioHigh()" to turn off LED. And you can modify the code in hal.h as below.

    //! \brief Defines the function to turn LEDs off
    #define HAL_turnLedOff HAL_setGpioHigh


    //! \brief Defines the function to turn LEDs on
    #define HAL_turnLedOn HAL_setGpioLow

    Best Regards,
    Yanming Luo