Dead Man's Switch

STM32 Watchdog Feed Exercise

Task

On a train, the driver must keep holding a handle called a dead man's switch, or the train brakes by itself. This board has a watchdog for the same job. A watchdog is a timer inside the chip that restarts the board if the program stops checking in for 1 second. Checking in is called feeding the watchdog.

A sample is one reading from the sensor. Log every sample as one line on the terminal, SAMPLE n with n counting from 1, for as long as the board runs: SAMPLE 1, SAMPLE 2, SAMPLE 3 and on, one per line Write main from the given functions.

Circuit

Block diagram: U2, the sensor, pulses its DRDY line into PA0 of U1, the STM32F4, once per sample; inside U1, main runs beside SysTick, a 1 ms timer in the core, and IWDG, the watchdog that restarts the chip after 1 second without a feed; USART1 sends each SAMPLE line on PA9 to a terminal

Pass condition

SAMPLE 1, SAMPLE 2 and on, one line per pulse on PA0, in order. The watchdog is started and fed after each sample, and never fed once the samples stop.

Expected when the sensor stops after three samples: PA0 pulses at 10, 20 and 30 ms and then stays low to 250 ms; the watchdog is fed once after each of the three samples and never again; the terminal shows SAMPLE 1 to SAMPLE 3

Notes

For each sample the sensor pulses PA0 high for 2 ms, about every 10 ms while your program runs, and may stop at any time.

Related challenges

Loading the interactive arena.