Subsection 9.3.6 Bounce, Now That Edges Matter
Contact bounce was a nuisance for polling and is a correctness problem for edge-triggered interrupts. A polling loop reads a level, and by the time it looks again the contacts have long since settled, so bounce is invisible to it unless the loop is very fast. The EXTI’s edge detector has no such luck: it fires on every falling edge, and an undebounced switch can deliver several within a few milliseconds. The result is one press that sets the pending flag repeatedly and one ISR that runs several times.
The hardware fix is the one already on your breadboard, the debouncing capacitor (Subsection 2.5.1), which slows the recovery enough that the voltage never climbs back above the input threshold during the bounce window. Figure 9.3.4 is what a debounced press looks like at the pin: one transition, 20 µs per division, no excursions. The software fix, when hardware debouncing is not an option, is for the ISR to record the time of the edge and ignore any further edge within a few tens of milliseconds, the same idea as the software debouncing we saw earlier, moved into the handler.
