Skip to main content
Explorer
December 1, 2025
Solved

STM32G4 Timer Break Interrupt Callback Function

  • December 1, 2025
  • 3 replies
  • 240 views

Hi All,

I'm using STM32G4 with TIM1 for motor control. The BKIN hardware protection works correctly - when I pull the BKIN pin (PB10) low, the motor stops, and when high, it runs again with AOE enabled. However, the break interrupt never fires and HAL_TIMEx_BreakCallback is never called. I've verified that TIM1_BRK_TIM15_IRQHandler exists in stm32g4xx_it.c, NVIC is enabled. The break flag never gets set even though BKIN is functioning. What could prevent the break flag from being set while the hardware break feature still works?

I want to print diagnostic using BKIN callback routing but it doesn't work.

I've attached IOC timer configurations.

Best regards

image_2025-12-01_225352148.pngimage_2025-12-01_225402390.pngimage_2025-12-01_225411569.pngimage_2025-12-01_225426620.png

    This topic has been closed for replies.
    Best answer by batuhanky

    Hey all,

    I think I understand the problem.

    HAL_TIMEx_PWMN_Start_IT function also enables the break interrupt so I think I need to manually enable the break interrupt when using the TIM_PWM_START_IT function.

     

    Best regards

    3 replies

    Super User
    December 1, 2025

    Does a breakpoint in TIM1_BRK_TIM15_IRQHandler ever get hit?

     

    batuhankyAuthor
    Explorer
    December 2, 2025

    Hey @TDK 

    No it doesn't get hit but there is an interrupt callback.

    When I ground the BKIN pin, the motor stops but printf does not work.

    batuhanky_0-1764702763640.png

     

    Technical Moderator
    December 2, 2025

    Hello @batuhanky 

    Could you please check if the break interrupt (BIE) is enabled in the TIMx_DIER register? 

    batuhankyAuthor
    Explorer
    December 2, 2025

    Hey @Saket_Om ,

    No, BIE is not set, but when I manually enable the BIE bit, the callback works. What could be the reason for this?

    TIM1->DIER |= (1 << 7);

     

    Technical Moderator
    December 3, 2025

    Hello @batuhanky 

    The API that you are using to start the timer is not enabling the break interrupt. 

    Try to use HAL_TIMEx_PWMN_Start_IT as suggested by @TDK

    Super User
    December 2, 2025

    Use HAL_TIMEx_PWMN_Start_IT to start the channel

    This would be much easier to diagnose if you showed your full code.