Skip to main content
FCHEN.2
Associate
February 9, 2023
Solved

STM32G4 Interrupt not working. The program always run default handler.

  • February 9, 2023
  • 2 replies
  • 2222 views

The code is generated by CubeMX. And every time program run into HAL_TIM_Base_Start_IT() like the figure below, the system will block in Default Handler. 0693W00000YALAhQAP.pngHowever, the TIM2_IRQHandler is defined in stm32g4xx_it.c.

0693W00000YALBaQAP.pngDoes anyone have idea why it doesn't work? I also attach the code.

This topic has been closed for replies.
Best answer by waclawek.jan

Code looks OK.

Check if the user FLASH is mapped to 0x00000000; in other words, check, if you don't boot into the default bootloader in System Memory.

Also check SCB_ICSR.VECTACTIVE value.

JW

2 replies

KnarfB
Super User
February 9, 2023

Your project works on my B-G431B-ESC1, tim_ticker incrementing as expected. STM32CubeIDE asked for migrating to the latest revision, what I did.

STMicroelectronics   STM32CubeMX   6.7.0.202211181646   com.st.stm32cube.common.feature.mx

STM32CubeIDE Version: 1.11.0 Build: 13638_20221122_1308 (UTC)

hth

KnarfB

waclawek.jan
waclawek.janBest answer
Super User
February 9, 2023

Code looks OK.

Check if the user FLASH is mapped to 0x00000000; in other words, check, if you don't boot into the default bootloader in System Memory.

Also check SCB_ICSR.VECTACTIVE value.

JW

FCHEN.2
FCHEN.2Author
Associate
February 10, 2023

Thanks! The problem is the boot mode. When I set boot from System memory, the program works well.