Skip to main content
LMorr.3
Senior
August 28, 2023
Solved

Starting EXTI disabled

I've used CubeMX to enable in PA4 as in input with EXTI interrupt enabled on a STM32F373.  It works well, but how to I enable the device with this interrupt disabled by default?  HAL seems to enable the interrupt and then allow the 'user' code' to be include just after but that will in fact trigger an interrupt in my case since a second device is toggling that pin quickly.  I only want the interrupt to be generated after some time after the device has booted to ensure it is ready.

 

Thanks!

This topic has been closed for replies.
Tesla DeLorean
Tesla DeLoreanBest answer
Guru
August 28, 2023

In most STM32 designs, the EXTI peripheral routes the interrupt. So for EXTI2, you associate PIN2 with the GPIO BANK (A,B,C,D,E,etc). Enable the IRQ in the NVIC. Have a service routine EXTI2_IRQHandler(). And with the HAL construct call back into the HAL so it can dispatch to the callback routine you've established.

Typically one can dispense with much of that overhead by servicing and clearing the EXTI in the EXTIx_IRQHandler() itself.

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..

4 replies

Tesla DeLorean
Guru
August 28, 2023

Do an initial configuration of the GPIO as an INPUT, and then later reconfigure it, or the EXTI peripheral, to associate with the pin.

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
LMorr.3
LMorr.3Author
Senior
August 28, 2023

Ok thanks.  I tried that and did not know how to add the interrupt function.  If I dont' use cubeMX it does not create the function for me.  Do I create an interrupt function in main.c like 'HAL_GPIO_EXTI_Callback'?

Tesla DeLorean
Tesla DeLoreanBest answer
Guru
August 28, 2023

In most STM32 designs, the EXTI peripheral routes the interrupt. So for EXTI2, you associate PIN2 with the GPIO BANK (A,B,C,D,E,etc). Enable the IRQ in the NVIC. Have a service routine EXTI2_IRQHandler(). And with the HAL construct call back into the HAL so it can dispatch to the callback routine you've established.

Typically one can dispense with much of that overhead by servicing and clearing the EXTI in the EXTIx_IRQHandler() itself.

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..