Skip to main content
Associate
November 27, 2025
Solved

MCSDK STSPIN32g4 disable via Vcc

  • November 27, 2025
  • 2 replies
  • 228 views

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.

 

Best answer by STuser2

The TIMx_BRK_M1_IRQHandler is used for over current protection as you can see below in MCSDK

STuser2_0-1764323662914.png

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.

2 replies

Senior III
November 28, 2025

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.

FavandAuthor
Associate
November 28, 2025

Hi, removing torque from the motor without using software allows to achieve better safety. That is why interrupting 12V to gate drivers is preferred

STuser2Best answer
Senior III
November 28, 2025

The TIMx_BRK_M1_IRQHandler is used for over current protection as you can see below in MCSDK

STuser2_0-1764323662914.png

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.

FavandAuthor
Associate
December 1, 2025

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.