Concept Flow - Why watchdog timer is needed
Start Program
Normal Operation
Watchdog Timer Reset
Check System Health
Continue
Restart Program
The watchdog timer monitors the system. If the system hangs, it triggers a reset to restart the program.
void main() {
while(1) {
kick_watchdog();
do_work();
}
}| Step | System State | Watchdog Timer | Action | Result |
|---|---|---|---|---|
| 1 | Program starts | Timer starts counting | Begin normal operation | System runs |
| 2 | Normal operation | Timer reset regularly | kick_watchdog() called | Timer does not expire |
| 3 | System hangs | Timer not reset | No kick_watchdog() call | Timer expires |
| 4 | Timer expires | Watchdog triggers reset | System reset initiated | Program restarts |
| 5 | After reset | Timer restarts | Program starts fresh | System recovers |
| Variable | Start | After Step 2 | After Step 3 | After Step 4 | Final |
|---|---|---|---|---|---|
| Watchdog Timer | 0 (started) | Reset to 0 repeatedly | Counts up (not reset) | Expired | Restarted at 0 |
Watchdog Timer monitors system health. If system hangs, timer expires. Timer expiry triggers system reset. kick_watchdog() resets timer regularly. Prevents system freeze by restarting. Essential for reliable embedded systems.