3 Replies Latest reply on Aug 6, 2017 11:48 PM by JoMe_264151

    Calling LED functions from an interrupt

      I need to implement a rapid blink of the LED. I have a watchdog timer that goes off every 100 ms . In the timer ISR I  set a toggle blink flag to tell the main loop to write a value to the LED This works for the most part but occasionally  the LED stays on or off longer than 100 ms/ I think it's because the main loop executes slower and less regularly than the timer. and the flag value gets out of sync with the current value of the LED.






      toggle_blink = !toggle_blink;




      main loop






      So the question is, is it OK to call WriteLED from the ISR?


      If the answer is yes, I need to check  a global variable to decide if the blink is needed. Wonder if that's OK too in the ISR