Vigil

STM32 Heartbeat Timeout Monitor Exercise

Task

U2 is the board next door. While alive, it pulses PA0 high on a steady beat. Watch that heartbeat with TIM3's count for as long as the board runs. The registers and bit fields are on the Datasheet tab.

Circuit

Block diagram: U2, another board, driving its heartbeat into U1 STM32F4 pin PA0, R1 pulling PA0 to ground when U2 does not drive it, TIM3 inside U1 fed by a 16 MHz timer clock, and pin PA9 carrying the USART1 report to TP1, a serial monitor

Pass condition

No heartbeat for 4 ms -> print LOST (not before 3.8 ms, by 4.2 ms). One arrives after LOST -> print BACK; otherwise -> print nothing.

Expected output for the public test: heartbeats on PA0 every 2 ms from 1 to 13 ms, then none until 20 ms; the serial monitor prints LOST at 17 ms, 4 ms after the last heartbeat, and BACK at 20 ms when the next one arrives, and nothing else

Notes

The given code sets up USART1 and printing, and starts TIM3 at 4 MHz. Your program is built and run at -O0, then at -O2. Both must pass.

Related challenges

Loading the interactive arena.