3 Replies Latest reply on Mar 16, 2017 9:34 PM by BoTa_264741

    Timer component--One Shot--ever


      This may have been solved before but I was unable to find the info.  Here's my solution:


      In trying to create a "soft switch" I connected a SPST pushbutton to a digital input pin and triggered a one shot timer with an interrupt on terminal count.  The timer was set for four seconds which means the PB had to be held for four seconds before the switch would be recognized and turn on and LED (used for testing).   However, I also wanted to turn it off by holding the same PB for another 4 seconds (after the PB had been released). Turning it on worked fine but it wouldn't turn off.  The problem is that the one-shot timer is REALLY one shot, meaning it will only work once after the program has been started.  It couldn't be reset from any API.  The only way to get it to work again was to restart the program.


      The solution was as simple as it could possibly be, though it took me a long time to figure it out.  I simply changed the timer's run mode to Continuous instead of One-Shot, then stopped the timer in the ISR.  The APIs work when the Continuous Mode is selected.