Is it possible to configure a GPIO input that sets a flag when rising or falling edge is detected without interrupting the CPU? I can then check the status of the flag in the main superloop? There is an option in CubeMX to configure the GPIO mode as "External Event Mode with Rising/Falling edge trigger detection" but I'm not sure how to read the event flag. Is this the correct mode to achieve this?
Asked
Active
Viewed 2,200 times
1 Answers
3
I'm not sure about the event mode (haven't used them before) but you could also use the
External Interrupt Mode with ...
as long as you don't activated the IRQ Handler in the NVIC the CPU is not interrupted by any pin change.
The information if an event/interrupt has occurred could be found in the EXTI_PR
register.
(See reference manual 12.3.6)

theSealion
- 1,082
- 7
- 13
-
1Thanks it turns out that in event mode the `EXTI_PR` register is not set (from Reference Manual RM0090) `"When the selected edge occurs on the event line, an event pulse is generated. The pending bit corresponding to the event line is not set."`. So I must use interrupt without enabling in NVIC. Is it possible to tell _which_ edge has been detected (rising or falling)? – b7031719 Mar 18 '19 at 17:34
-
3Unfortunately it is not possible to tell which edge has been detected. If your signal changes slow enough, you could use the actual level of the pin to determine the edge (If `IDR & Pin` is true, the last edge was a rising one :) ) Or you could use two pins. One to detect rising and one for the falling edges. – theSealion Mar 19 '19 at 07:06