Skip to main content
DavePfz
Senior
Oct 26, 2026 9:10 PM UTC
Solved

When/where are interrupts enabled?

I have built up a project using FreeRTOS and STM32_WPAN on an STM32WB55M. It also implements the VBAT for the RTC and uses the EXTI0 and EXTI1 interrupts.

The problem I’m having is that as soon as MX_GPIO_Init() completes an interrupt is generated, but the supporting FreeRTOS queues have not yet been defined and the program just hangs.

My presumption was that on a reset (restart in the debugger) interrupts were disabled, but what I’m seeing doesn’t support this.

What have I missed?

TDK
TDKBest answer
Oct 26, 2026 11:33 PM UTC

However, my question was more about where and when the global interrupts are enabled - usually via the __enable_irq() macro.

Globally, interrupts are enabled after reset in the sense that __enable_irq() is active. It is not called explicitly--that is the default as-reset state.

However, no interrupts will fire until they are individually enabled. Put a __disable_irq() before MX_GPIO_Init if that’s what you want and then __enable_irq when you are ready to handle them.

"If you feel a post has answered your question, please click ""Accept as Solution""."

3 replies

TDK
Oct 26, 2026 10:02 PM UTC

When/where are interuots enabled?

The problem I’m having is that as soon as MX_GPIO_Init() completes an interrupt is generated

Interrupts are disabled on startup.

They are enabled in HAL_GPIO_Init which is called within MX_GPIO_Init.

Lots of solutions here. Disable interrupts until you’re ready to receive them. Don’t call MX_GPIO_Init during startup until you are ready.

"If you feel a post has answered your question, please click ""Accept as Solution""."
DavePfz
DavePfzAuthor
Senior
Oct 26, 2026 10:25 PM UTC

I think you misunderstood my question. I fully understand that the EXTI0 and EXTI1 interrupts are enabled in MX_GPIO_Init(). Using STM32CubeMX, it will not allow me to reorder the first three initializations of which MX_GPIO_Init() is the second one. So, your suggestion is not in the normal realm.

However, my question was more about where and when the global interrupts are enabled - usually via the __enable_irq() macro. If the global interrupts are disabled, then the interrupts I’m seeing now will not happen.

I would expect the global interrupts to be enabled at the start of the FreeRTOS kernel. However, the program is never getting that far.

TDK
TDKBest answer
Oct 26, 2026 11:33 PM UTC

However, my question was more about where and when the global interrupts are enabled - usually via the __enable_irq() macro.

Globally, interrupts are enabled after reset in the sense that __enable_irq() is active. It is not called explicitly--that is the default as-reset state.

However, no interrupts will fire until they are individually enabled. Put a __disable_irq() before MX_GPIO_Init if that’s what you want and then __enable_irq when you are ready to handle them.

"If you feel a post has answered your question, please click ""Accept as Solution""."