Skip to main content
FLomb.2
Visitor II
July 19, 2022
Solved

STM32CubeMX 6.6.1 "Generate Enable in Init" does not work as expected for external interrupts

  • July 19, 2022
  • 5 replies
  • 2968 views

When attempting to initialize a single GPIO EXTI as disabled, the generated code still enables the interrupt. I did notice that if I uncheck all of the EXTI lines, then none of them are enabled in the generated code. So it seems it's all or nothing. Is this the expected behavior?

Thanks,

Frank

This:

0693W00000QLTFGQA5.pngGenerates:

 /* EXTI interrupt init*/
 HAL_NVIC_SetPriority(EXTI0_IRQn, 5, 0);
 HAL_NVIC_EnableIRQ(EXTI0_IRQn);
 
 HAL_NVIC_SetPriority(EXTI2_IRQn, 6, 0);
 HAL_NVIC_EnableIRQ(EXTI2_IRQn);
 
 HAL_NVIC_SetPriority(EXTI3_IRQn, 6, 0);
 HAL_NVIC_EnableIRQ(EXTI3_IRQn);
 
 HAL_NVIC_SetPriority(EXTI4_IRQn, 6, 0);
 HAL_NVIC_EnableIRQ(EXTI4_IRQn);

However, this:

0693W00000QLTFfQAP.pngGenerates:

 /* EXTI interrupt init*/
 HAL_NVIC_SetPriority(EXTI0_IRQn, 5, 0);
 HAL_NVIC_SetPriority(EXTI2_IRQn, 6, 0);
 HAL_NVIC_SetPriority(EXTI3_IRQn, 6, 0);
 HAL_NVIC_SetPriority(EXTI4_IRQn, 6, 0);

Best answer by Sara BEN HADJ YAHYA

Hello @FLomb.2 (Community Member)​ & @KnarfB (Community Member)​ ,

Thanks for your feedback,

This is a known issue and it is already raised to the dev team. When "Generate enable in init" is unchecked, its respective HAL_NVIC_EnableIRQ(XXXX_IRQn) should not be generated.

I will keep you posted with updates

Internal ticket number: 129363 (This is an internal tracking number and is not accessible or usable by customers).

If your issue is solved, please close this post by clicking the "Select as Best" button. This will help other members of the community find this response more quickly :)

Sara.

5 replies

KnarfB
Super User
July 19, 2022

Confirmed on NUCLEO_STM32G431KB PA4 and PB0. Flagged as bug-report.

hth

KnarfB

Amel NASRI
Technical Moderator
July 20, 2022

Hi @FLomb.2​  & @KnarfB​ ,

Thanks for reporting the issue and adding relevant topics.

I add @Sara BEN HADJ YAHYA​ & @Khouloud OTHMAN​ to investigate it and take relevant actions.

-Amel

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
ST Employee
July 29, 2022

Hello @FLomb.2 (Community Member)​ & @KnarfB (Community Member)​ ,

Thanks for your feedback,

This is a known issue and it is already raised to the dev team. When "Generate enable in init" is unchecked, its respective HAL_NVIC_EnableIRQ(XXXX_IRQn) should not be generated.

I will keep you posted with updates

Internal ticket number: 129363 (This is an internal tracking number and is not accessible or usable by customers).

If your issue is solved, please close this post by clicking the "Select as Best" button. This will help other members of the community find this response more quickly :)

Sara.

Sune Jensen
Associate II
December 13, 2023

The call to HAL_NVIC_EnableIRQ(XXXX_IRQn) seems to be correctly omitted when the initialization code is generated in main.c. It is erroneously called when the initialization code is generated in gpio.c.

See my related bug report: https://community.st.com/t5/stm32cubemx-mcus/bug-report-exti-irq-erroneously-enabled-when-initializing-in/m-p/619087

Explorer
December 2, 2025

The problem still exists in CubeMX Version V6.16.0. With STM32L496 and "generate peripheral initialization as pai of .c/.h files per peripheral" checked

Ghofrane GSOURI
Technical Moderator
December 2, 2025

Hello @lbrosen 

I performed a test using STM32CubeMX 6.16.0 and STM32CubeIDE 2.0.0 and it's working correctly.

Could you please retest using a from scratch IOC?

GhofraneGSOURI_0-1764677794349.png

 

THX

Ghofrane

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.