0
0
FreeRTOSprogramming~10 mins

Watchdog task pattern in FreeRTOS - Step-by-Step Execution

Choose your learning style9 modes available
Concept Flow - Watchdog task pattern
Start Watchdog Task
Wait for Notification
Check if Task Responded
Reset Timer
Loop to Wait Again
The watchdog task waits for a signal from monitored tasks. If it receives timely signals, it resets its timer. If not, it triggers a system reset.
Execution Sample
FreeRTOS
void WatchdogTask(void *pvParameters) {
  for(;;) {
    if(xTaskNotifyWait(0, 0, NULL, pdMS_TO_TICKS(1000)) == pdTRUE) {
      ResetWatchdogTimer();
    } else {
      SystemReset();
    }
  }
}
This FreeRTOS task waits for a notification every 1000 ms; if received, it resets the watchdog timer, else it resets the system.
Execution Table
StepActionNotification Received?Watchdog Timer Reset?System Reset Triggered?
1Wait for notification (timeout 1000ms)NoNoNo
2Timeout expired without notificationNoNoYes
3System reset triggered---
4Restart after reset, begin waiting again---
5Wait for notification (timeout 1000ms)YesNoNo
6Notification received, reset watchdog timerYesYesNo
7Loop back to wait for next notification---
💡 System reset triggered when no notification is received within 1000 ms timeout
Variable Tracker
VariableStartAfter Step 1After Step 2After Step 5After Step 6Final
Notification ReceivedFalseFalseFalseTrueTrueTrue
Watchdog Timer ResetFalseFalseFalseFalseTrueTrue
System Reset TriggeredFalseFalseTrueFalseFalseFalse
Key Moments - 3 Insights
Why does the system reset if no notification is received?
Because the watchdog task waits for a notification within a timeout (step 1 and 2). If it times out without receiving it, it triggers a system reset (step 3).
What happens when a notification is received on time?
The watchdog timer is reset (step 6), preventing system reset and allowing the task to wait again (step 7).
Why is the watchdog timer reset important?
Resetting the watchdog timer signals the system is healthy. Without it, the watchdog assumes a fault and triggers a reset (see steps 2 and 3).
Visual Quiz - 3 Questions
Test your understanding
Look at the execution table, what happens at step 2?
ANotification received and watchdog timer reset
BTimeout expired without notification
CSystem reset completed
DTask waits for notification
💡 Hint
Check the 'Notification Received?' and 'System Reset Triggered?' columns at step 2
At which step does the system reset get triggered?
AStep 1
BStep 5
CStep 3
DStep 7
💡 Hint
Look at the 'System Reset Triggered?' column in the execution table
If the notification is always received on time, what will never happen?
ASystem reset triggered
BWatchdog timer reset
CWaiting for notification
DLooping back to wait again
💡 Hint
Refer to variable_tracker and execution_table rows where 'System Reset Triggered' is false when notification is true
Concept Snapshot
Watchdog Task Pattern in FreeRTOS:
- Task waits for notification with timeout
- If notification received: reset watchdog timer
- If timeout: trigger system reset
- Loop repeats indefinitely
- Ensures system health by monitoring task responsiveness
Full Transcript
The watchdog task pattern in FreeRTOS involves a dedicated task that waits for notifications from monitored tasks within a set timeout period. If the notification arrives on time, the watchdog timer is reset, indicating the system is healthy. If the notification does not arrive before the timeout expires, the watchdog task triggers a system reset to recover from potential faults. This cycle repeats indefinitely, ensuring the system remains responsive and safe. The execution table shows steps where the task waits, checks notifications, resets timers, or triggers resets. Variables track notification receipt, timer resets, and system resets. Key moments clarify why resets happen and the importance of timely notifications. The visual quiz tests understanding of these steps and outcomes.