Skip to main content
Adam Hamilton
Senior
November 17, 2021
Question

Don't enable interrupts

  • November 17, 2021
  • 5 replies
  • 3367 views

I would like to know if there is a way to NOT enable interrupts during the initialization of the EXTI. See below for snippet

 /* EXTI interrupt init*/
 HAL_NVIC_SetPriority(EXTI0_IRQn, 0, 0);
 HAL_NVIC_EnableIRQ(EXTI0_IRQn);
 
 HAL_NVIC_SetPriority(EXTI3_IRQn, 0, 0);
 HAL_NVIC_EnableIRQ(EXTI3_IRQn);

I want to be able to control when I enable the IRQ but there doesn't seem to be any option to do this.

if I uncheck the Enabled option within the NVIC Configuration tab, it completely removes the setup and IRQ callback, which is not what I want.

Basically, I want something like

 /* EXTI interrupt init*/
 HAL_NVIC_SetPriority(EXTI0_IRQn, 0, 0);
 HAL_NVIC_DisableIRQ(EXTI0_IRQn);
 
 HAL_NVIC_SetPriority(EXTI3_IRQn, 0, 0);
 HAL_NVIC_DisableIRQ(EXTI3_IRQn);

I just don't see any way to accomplish this. I suppose in my current circumstance I could initialise before the MX_GPIO_Init() function, that way I can be certain that if the external interrupt fires, my code will be ready for it.

However, there might be other situations where this won't be possible. In any case, if there is no way to accomplish something like the snippet above, can I request that for a future version of CubeMX for both standalone and IDE integration, the IRQ enablement is selectable via a checkbox

Sorry if this seems overly worded. Also, I would normally add this as a feature request but ST community seems to only do Q&A

Thanks

Adam

5 replies

Herve PIERROT
ST Employee
November 17, 2021

Hi Adam,

Thanks for sharing your ideas. This forum is a good place for it, and we will have a look to it, but maybe you can also duplicate your post

in the IdeaZone, in the menu Share->Ideas

0693W00000GXqx5QAD.png 

Thanks,

Herve.

Adam Hamilton
Senior
November 17, 2021

Thanks for looking into it Herve

I will certainly duplicate my post in the Ideas section.

Regards

Adam

TDK
Super User
November 17, 2021

@Herve PIERROT​ 

Ah yes, the idea zone. Where in 2 years, there have been 5 things marked as "Delivered," but none since 2021 began. Out of those, 3 are TouchGFX specific, 1 is a forum request, and 1 is a request to rename PDFs.

The idea zone concept is nice, but it doesn't really work without ST engagement and support.

"If you feel a post has answered your question, please click ""Accept as Solution""."
Adam Hamilton
Senior
November 17, 2021

Thanks @TDK​ 

I will do my due diligence and report it in the IdeaZone, although given what you said I do not hold much hope.

Thanks

Adam

Pavel A.
Super User
November 17, 2021

If you do not want to enable certain interrupts during initialization, then just uncheck the Enabled option.

Configure and enable these interrupts later when you're ready to handle them.

There is another way to hold enabled interrupts during initialization, using BASEPRI.

Adam Hamilton
Senior
November 18, 2021

I have already considered this, and was mentioned in my OP: "if I uncheck the Enabled option within the NVIC Configuration tab, it completely removes the setup and IRQ callback, which is not what I want."

I'll look into BASEPRI but somehow I think this a hammer approach to something that could be quite easilly solved by allowing the programmer to control when the IRQ is to be handled.

Khouloud ZEMMELI
ST Employee
November 18, 2021

Hello @Adam Hamilton​ ,

Thanks for your post,

Your request will be internally checked.

Khouloud.

Adam Hamilton
Senior
November 18, 2021

Thanks for looking into this. I have also submitted to the IdeaZone where hopefully it can be better tracked

https://community.st.com/s/ideazone#0873W000000fxYJQAY

Kind regards

Adam

NPato
Associate III
June 13, 2024

Looks like they killed off IdeaZone but still no (obvious) solution to this request? 

It's a fairly important requirement to have control of when interrupts are enabled, I'm fine with it defaulting to enabling the interrupts but there should also be a way to override this. This is a serious problem, that can cause nasty problems with systems not booting in odd scenarios. It's made worse because the HAL needs global interrupts enabled as some of the initialisation functions (USB for example) use HAL_Delay that relies on the tick interrupt.

I'll probably work around this by disabling the EXTI in the NVIC config and then manually adding the interrupt vectors in user code and then enabling the EXTI interrupt when user code is ready. 

Cheers

Nigel