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.

LAUNCHXL-F28377S: One User Led is on and the other off before main runs. Why?

Part Number: LAUNCHXL-F28377S


Why do the blue user LED is off and the red user LED is on before main runs? I would expect both of the them to be off, so the user can turn them on according to their application.

In this video between minute 15-16, we can see how the red one is on and the blue off.

https://youtu.be/6_HxKOE9nNM

Thank you.

  • Jose,

    Thanks for the question and for the nice video.

    What you're seeing is the difference in speed between the code and the I/O pin.  When an I/O pin changes state it takes a finite amount of time for the pin voltage to change from one logic state to another.  The instructions used in your code compile to "atomic" read-modify-write" instructions, which first read the pin state, perform a logical AND on the result, then write the result back.  When you perform two of these in quick succession the pin timing comes into effect because the instruction time is faster then the pin.  You can read more about it on this Wiki page:

    The solution is to separate the two instructions with NOPs, like this:

    asm(" NOP");

    ...or use the GPIO SET/CLEAR/TOGGLE registers instead of writing directly to the DAT register.

    I hope this helps.

    Regards,

    Richard

  • Thank you, Richard. It helps a lot and now I think I understand better. But, before main runs, none of my code has run yet. What happened before main that makes one led off and the other on? After reset, the mcu goes to BOOT ROM and then jump to code_start, does something , and then run main. Are you suggesting that before main, in some system initialization, the two leds were manipulated back-to-back creating the timing issue you mention so that one is on and the other off? If so, it would be nice to fix that. Regards.
  • Jose,

    The timing issue I explained affects your code. There is nothing in the boot ROM which configures the GPIO this way.

    The reason for the different I/O status on start-up is the hardware connections on the LP board. GPIO13 is in parallel connected through a level shifter (U2) to a QEP index pin which has a pull-up resistor on it, whereas GPIO12 has no such connection. This is what keeps the blue LED off on start-up, otherwise I think they would both be on. It's just the way the board was designed.

    Regards,

    Richard
  • Thank you. That explains it. Just I need to make sure they are both off before I use them