Tally

STM32 Burst of Interrupts Logging Exercise

Task

A Geiger counter clicks once for each particle of radiation it detects. Clicks come at random, mostly far apart but sometimes two or three within a few milliseconds. Each click goes to the lab over a slow radio link as one line, and none may be lost.

Send one line per click, numbered from 1, in order, for as long as the board runs: CLICK 1, CLICK 2, CLICK 3 and on, one per line The core is the part of the chip that runs your code. Each click makes it pause main and run the interrupt handler EXTI0_IRQHandler. Write its body, anything it needs outside every function, and a main that starts the board with the given functions. Every line goes out through report().

Circuit

Block diagram: U2, the Geiger counter's detector, pulses PA0 of U1 STM32F4 once per click; inside U1, EXTI0_IRQHandler runs for each click, main runs the rest of the time, and the given report() sends one line on USART1 TX, PA9, to the radio link in 5 ms

Pass condition

Each click gets one CLICK line in number order, none missing. The core runs EXTI0_IRQHandler once for every click.

Expected output for the burst case: PA0 clicks at 10 ms, three times at 30, 31 and 32 ms, and at 60 ms; the core runs EXTI0_IRQHandler once per click, five times; the radio gets CLICK 1 to CLICK 5, one line each, in order

Notes

The detector pulses PA0 high for 0.2 ms per click while your program runs. Some clicks come 1 ms apart. Like the radio, report() takes 5 ms a line. Leave the given code as it is. Your program is built and run at -O0, then again at -O2. Both builds must pass.

Related challenges

Loading the interactive arena.