2025-11-27 7:49 AM
Hello,
I'm working with a custom board that uses an external 12V supply for the VCC pin (gate driver supply) of STSPIN32g4. The VCC supply is interrupted by external circuitry whenever a fault is detected.
The problem I'm encoutering is that when the 12V is removed the firmware gets stuck by continuously calling the interupt "TIMx_BRK_M1_IRQHandler" in the file "stm32g4xx_mc_it.c" and no other code gets executed.
I tried to stop the timer calling this interrupt but without success.
The goal is to remove torque to the motor by hardware as if being connected to an enable/disable input.
Thank you in advance.
Solved! Go to Solution.
2025-11-28 1:56 AM
The TIMx_BRK_M1_IRQHandler is used for over current protection as you can see below in MCSDK
Also an ST document explaining it How to use PWM shutdown for motor control and digital power conversion on STM32 MCUs - Application note
So, in your when you remove 12V there is over current triggered. To avoid it you need remove the protection which is off course not recommended.
2025-11-27 7:12 PM - edited 2025-11-27 7:13 PM
If any fault is detected, you can give stop motor command instead of interrupting 12V to gate drivers. But i am not sure if STSPIN32g4 architecture is like that.
2025-11-28 12:06 AM
Hi, removing torque from the motor without using software allows to achieve better safety. That is why interrupting 12V to gate drivers is preferred
2025-11-28 1:56 AM
The TIMx_BRK_M1_IRQHandler is used for over current protection as you can see below in MCSDK
Also an ST document explaining it How to use PWM shutdown for motor control and digital power conversion on STM32 MCUs - Application note
So, in your when you remove 12V there is over current triggered. To avoid it you need remove the protection which is off course not recommended.
2025-12-01 12:55 AM
Hi, thank you for your help.
The firmware is now working correctly ☺️
I disable the BRK input when the 12V is removed and re-enable it when the voltage is supplied.