In this lesson, you will learn how windowed watchdog timers go beyond basic resets by enforcing both a minimum and maximum execution time for your critical tasks.
Beyond the Simple Kick
Standard watchdog timers are designed to catch "task hangs"—if the system doesn't reset the timer before it expires, the processor assumes the software has locked up and triggers a system reset. However, a standard watchdog is blind to tasks that execute too quickly. If your task finishes in 1ms when it should take at least 10ms (perhaps due to a logic error that skipped a critical calculation), a standard watchdog won't notice.
A Windowed Watchdog Timer (WWDT) solves this by defining an "open window" for the reset. You can only "kick" the watchdog during this specific time interval.
The Timing Constraint
The WWDT introduces two boundaries:
- The Lower Bound: If you try to kick the watchdog before this time, it triggers a fault. This detects code that is running dangerously fast, indicating that the control logic has likely bypassed important steps.
- The Upper Bound: If you fail to kick the watchdog by this time, it triggers a fault. This detects the traditional task hang.
Consider a motor control loop that must execute every 20ms. You might set your WWDT window between 15ms and 19ms:
void motor_control_task(void) {
// Perform critical calculations
do_calculations();
// Check if we are inside the valid window
if (get_time_since_last_kick() > MIN_WINDOW_MS) {
if (get_time_since_last_kick() < MAX_WINDOW_MS) {
kick_watchdog();
} else {
handle_timing_error(); // Too slow!
}
} else {
handle_timing_error(); // Too fast!
}
}
By enforcing these bounds, you ensure your software remains deterministic. If the task finishes too early, the windowed watchdog catches a logic failure; if it finishes too late, it catches a resource contention or loop hang. This adds a critical layer of temporal integrity to your safety-critical system.
Key Takeaway: Windowed watchdog timers provide high-fidelity reliability by forcing your software to operate within a strictly defined temporal envelope, catching both hangs and erratic, premature execution.