Use Freertos with WDT(watch dog timer)


we are using freertos with wdt, and it seems more complicated than single task program.

if it is a single task program, I just reset wdt periodically in that task.

but when it comes to multitask program, I could not reset wdt in each task. for it still runs

when one of them got stuck.

I’m also considering using timer. reset wdt in timer fired event.

how do you usually use wdt with freertos?


I usually put the kick opration in idle hook, which will be done by idle task who is be set the lowest priority.the reson is :so much so that the lowest priority task be starved, a wtd reset required now.
And,I would take care of any opinion by others.
I found this is a FAQ in FreeRTOS. and i didn’t see any satisfying and simple measure.

I’m using a similar scheme because it’s good enough for my use case.
If you need to monitor the state of other/all tasks of your application you need to implement that yourself. A simple solution could be to check for changes of a heartbeat counter incremented by each task if they run periodically in the task/hook keeping the WDT alive.

This is what all the FreeRTOS demos do. Many of the demo tasks run tests - if a test fails it stops incrementing the heartbeat. If the task stalls or doesn’t get CPU time then the heartbeat stops by itself. A central monitoring task then looks at all the heartbeats - in your case if a heartbeat stops you can take appropriate action, which may be to stop kicking the WDT.