Switchboard

STM32 GPIO Input Register Exercise

Task

The switches on PB0 and PB1 go on and off while your program runs. Make each LED follow its switch for as long as the board runs: if PB0 is on -> PA5 on; if PB0 is off -> PA5 off. if PB1 is on -> PA6 on; if PB1 is off -> PA6 off. The registers and bit fields are on the Datasheet tab.

Circuit

Block diagram: SW1 from +3V3 into U1 STM32F4 pin PB0 and SW2 into pin PB1 on port B, and pins PA5 and PA6 on port A each driving a 330 ohm resistor into an LED to ground, with a TP1 logic analyzer probing the PA5 and PA6 nets

Pass condition

Each LED changes only when its own switch does. A glitch while you set up the ports counts as an edge too.

Expected trace for the mixed case: PB0 high then low, PB1 high then low afterwards, PA5 following PB0 with two edges and PA6 following PB1 with two edges

Notes

The bench drives PB0 and PB1 directly, so you need no pull-up or pull-down. This question needs no clock enable.

Related challenges

Loading the interactive arena.