Page 1 of 1
timer self-overlay
Posted: Mon Jul 05, 2021 11:57 am
by nesergen
I added a timer to the program, but I can't figure out one thing. Set the timer to fire every 1 second. Now the timer will perform a certain task. But what if the duration of the task is more than 1 second? It turns out that the timer will work again and interrupt the execution of the previous task and restart it? And then the task will never be completed? Or is the timer unable to interrupt itself?
Re: timer self-overlay
Posted: Mon Jul 05, 2021 7:03 pm
by davef
Search for <Simple software WDT implementation> on the forum. I use a 70 second time period.
I think wdt_callback() and wdt_feed() takes care of the problem you raise.
Re: timer self-overlay
Posted: Tue Jul 06, 2021 6:38 am
by jimmo
nesergen wrote: ↑Mon Jul 05, 2021 11:57 am
Or is the timer unable to interrupt itself?
That's right.
Depending on which port/board you're using for the specific implementation, but neither a hard or soft IRQ can interrupt themselves.
In general it's a really bad idea to have interrupt handlers take long to execute (i.e. they should do the minimum possible work, i.e. set a flag), and then have your main program deal with the flag.