STM32 gotchas
147. Slow input signal slew rate may cause multiple interrupts (especially with EXTI, which is asynchronous)

On STM32 pins, digital input circuitry conditions the input signal using a Schmitt circuit, effectively introducing hysteresis of cca 200mV to the input decision level. This means, that a slowly rising or falling signal should not cause several input level transitions, as long as the rise or fall is monotonic.

However, as soon as there is any noise or interference with amplitude of more than cca 200mV superimposed on this slowly rising/falling signal, the input may see several transitions between 0 and 1 in rapid succession.

Hundreds of millivolts of noise are not a rare sight in digital circuits. As long as all signals in the circuit are "perfectly digital", i.e. they are driven between GND and VDD by relatively low impedance drivers, resulting in sharp transitions/edges, such noisy circuit still may function quite well as expected, and the noise may go unnoticed.

Slowly rising/falling signals on the other hand tend to result from being driven by a high-impedance source, making them even more prone to interference through capacitive or inductive coupling from neighbouring circuits/tracks. Additionally, improperly routed and/or decoupled power supply and ground may introduce additional noise to signal through voltage drops on common tracks impedance, resulting from the pulsed power consumption of massive digital circuitry such as the mcu itself.

The surprise is often associated also with the less-known fact, that - in contrast to interrupts associated e.g. with TIM input capture - the EXTI interrupts are asynchronous, i.e. they react on pulses shorter than the maximum system clock frequency of given STM32 model, regardless of the actually used system clock frequency. If EXTI is set to react on both edges, such pulse will the cause both interrupt source to latch, thus resulting in two (or more, if there's more such noise) consecutive ISR execution.

While using for example TIM channels (which feature also an optional digital filter) instead of EXTI may reduce impact of such unwanted noise, it's better to design the circuit so that overall circuit noise is reduced, and slowly rising/falling and/or weakly driven signals are avoided.