Skip to main content
Associate II
Dec 1, 2025 7:56 PM UTC
Solved

STM32G4 Timer Break Interrupt Callback Function

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

batuhankyBest answer
Associate II
Dec 3, 2025 6:56 PM UTC

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

8 replies

TDK
Dec 1, 2025 8:15 PM UTC

Does a breakpoint in TIM1_BRK_TIM15_IRQHandler ever get hit?

 

"If you feel a post has answered your question, please click ""Accept as Solution""."
batuhankyAuthor
Associate II
Dec 2, 2025 7:14 PM UTC

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

 

ST Technical Moderator
Dec 2, 2025 8:36 AM UTC

Hello @batuhanky 

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

In order to give better visibility on the answered topics, please click on 'Best answer' on the reply which solved your issue or answered your question. Saket_Om
batuhankyAuthor
Associate II
Dec 2, 2025 7:22 PM UTC

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);

 

ST Technical Moderator
Dec 3, 2025 8:52 AM UTC

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. 

In order to give better visibility on the answered topics, please click on 'Best answer' on the reply which solved your issue or answered your question. Saket_Om
TDK
Dec 2, 2025 7:38 PM UTC

Use HAL_TIMEx_PWMN_Start_IT to start the channel

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

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