Doorbell

STM32 Button Interrupt Exercise

Task

On a coin-cell doorbell, the button on PA0 is pressed and released while your program runs. From EXTI0_IRQHandler (IRQ 6), control the LED on PA5 for as long as the board runs: if pressed -> LED on; if not pressed -> LED off. The registers and bit fields are on the Datasheet tab.

Circuit

Block diagram: SW1 pulls PA0 of U1 STM32F4 up to 3V3 against a 10k pulldown, PA5 drives R1 330R into D1 LED to ground, and a TP1 logic analyzer probe sits on the PA5 net

Pass condition

PA5 follows every press and release, and the core takes IRQ 6 for every edge.

Expected trace: the bench presses and releases PA0, EXTI0_IRQHandler runs once at the press and once at the release, and PA5 goes high on the press and low on the release, one pulse per press

Notes

This question needs no clock enable. PA0 is EXTI line 0, and line 0 reaches the core as IRQ 6.

Related challenges

Loading the interactive arena.