2025-03-04 5:49 AM
Heyho,
I'm currently using a GPIO on a STM32L031 for a custom 1-wire interface, which means it's switching all the time between input and output mode (open drain).
So far I have learned that the EXTI interrupt only works with GPIOs in input mode.
My question:
Once I have enabled the EXTI for a certain GPIO in input mode, then change the GPIO mode to output, then back to input, do I have to re-enable the EXTI somehow, or is it still working as before?
Thanks in advance!
Solved! Go to Solution.
2025-03-04 8:09 AM
> in non-input mode the GPIO simply doesn't trigger the EXTI
No. "EXTI is independent from GPIO" means, that no matter how the pin is set in GPIO (except for Analog, when the digital input is disconnected entirely), EXTI works out of the edges it sees at given pin.
In other words, if you set a pin to trigger EXTI, and you set that pin as Output in GPIO, then if you by that output generate an edge for which EXTI is set up, that edge *will* trigger EXTI.
JW
2025-03-04 5:55 AM - edited 2025-03-04 5:56 AM
I think I found the answer here, in Jan's reply (thanks!):
How to change GPIO pin mode efficiently - STMicroelectronics Community
EXTI and GPIO are completely independent, so in non-input mode the GPIO simply doesn't trigger the EXTI.
Then I have to look elsewhere for my precious bugs... ;)
2025-03-04 8:09 AM
> in non-input mode the GPIO simply doesn't trigger the EXTI
No. "EXTI is independent from GPIO" means, that no matter how the pin is set in GPIO (except for Analog, when the digital input is disconnected entirely), EXTI works out of the edges it sees at given pin.
In other words, if you set a pin to trigger EXTI, and you set that pin as Output in GPIO, then if you by that output generate an edge for which EXTI is set up, that edge *will* trigger EXTI.
JW
2025-03-04 8:27 AM
So far, not so good:
after a lot of testing I'm pretty sure that:
either the EXTI is triggered with the GPIO not only in input mode,
or there's kinda race condition, meaning that output is switched to output before EXTI knows GPIO is not in input mode anymore.
1) GPIO is in input mode + pull-up -> line is high (verified on the scope)
2) then GPIO is switched to low output / open drain, pulling the line low (verified on the scope)
3) EXTI is triggered: falling edge
That a known issue?
2025-03-04 8:55 AM
somehow the browser didn't refresh...
anyway, thanks for the clarification!
2025-03-04 9:00 AM
Then ST should change this in the Ref Manual (RM0377 for L0x1):
It's at least ambiguous.