cancel
Showing results for 
Search instead for 
Did you mean: 

Starting EXTI disabled

LMorr.3
Senior II

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!

1 ACCEPTED SOLUTION

Accepted Solutions

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
Up vote any posts that you find helpful, it shows what's working..

View solution in original post

4 REPLIES 4

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
Up vote any posts that you find helpful, it shows what's working..

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'?

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
Up vote any posts that you find helpful, it shows what's working..

Thanks, creating a EXTI4_IRQHandler() in main.c worked as I expected.

Is there a doc with all the IRQ handlers HAL looks for?