Wait for It

STM32 Data Ready Pin Exercise

Task

A sensor takes its time to finish a measurement and cannot say in advance when it will be done. When a new reading is ready, the sensor raises a wire called the data-ready line, and the chip watches that wire. On this board the line comes in on PA0, and the LED on PA5 shows that the chip has seen it.

Make the LED follow the line, like this: PA0 low: LED off. PA0 rises: LED on within 1 ms, and on for good. PA0 rises at most once, at a moment you cannot predict. The registers are on the Datasheet tab, under GPIOA.

Circuit

Block diagram: U2 sensor's DRDY output wired to U1 STM32F4 pin PA0 with a common ground, and pin PA5 driving R1 330R into D1 LED to ground, with a TP1 logic analyzer probe on the PA5 net

Pass condition

PA5 rises once, within 1 ms of PA0, and stays high. If PA0 never rises, PA5 never moves.

Expected output: PA0 rises once at a moment the program cannot predict and stays high, and PA5 rises once within 1 ms of it and stays high, one edge in all

Notes

PA0 is already an input when the program starts, so it needs no setup.

Related challenges

Loading the interactive arena.