Night Watch
STM32 Independent Watchdog Exercise
Task
A night watchman walks the same round of a building all night. At the end of each round he turns a key in a clock on the wall. If he ever stops, the clock rings and wakes the caretaker. A watchdog is that clock, inside the chip. It is a timer of its own that restarts the chip if the program stops checking in. Checking in is called feeding the watchdog.
Walk the rounds for as long as the board runs, and feed the watchdog once after each round: ROUND 1, ROUND 2, ROUND 3 and on, one per line Two registers set the watchdog's timeout. PR is the prescaler and RLR is the reload. Start the watchdog with PR = 3 and RLR = 999, then call walk_round(n) for round n, n counting from 1. The registers and bit fields are on the Datasheet tab.
Circuit
Pass condition
ROUND 1, ROUND 2 and on, one line per round, in order. The watchdog is set to PR = 3 and RLR = 999 in a way the chip accepts, started, and fed once after each round.
Notes
PR = 3 and RLR = 999 give the watchdog 1 second. Without a feed for 1 second, the watchdog restarts the chip. The watchdog counts on its own 32 kHz clock, which needs no setup.