Skip to main content
Associate II
September 6, 2025
Question

A hardware fault is reported after pressing a button to initiate the pre-charge process (6.4.0 SDK/STM32G431)

  • September 6, 2025
  • 1 reply
  • 574 views

您好,我已经在STM32G431上成功配置了 6.4.0 SDK 包。 但是,当我按下按钮并开始预充电过程时,报告了硬件故障。 如果我在预充电过程中将上侧 PWM 波的刻度值从 0% 更改为 90%,程序将在 RUN 后进入 STOP 状态,然后进入故障状态。故障代码为 40,定义为 #define MC_BREAK_IN ((uint16_t)0x0040) /**< @brief 错误:紧急输入(过流)。 */

Post edited by ST moderator to follow the community rule which is using English language. So in next time please use English as it's an international community and to let others to understand your post. Thank you for your understanding.

Translation:

Hello, I have successfully configured the 6.4.0 SDK package on my STM32G431. However, when I press the button to initiate the pre-charge process, a hardware fault is reported. If I change the duty cycle of the upper PWM waveform from 0% to 90% during the pre-charge process, the program enters a STOP state after running, and then enters a fault state. The fault code is 40, which is defined as #define MC_BREAK_IN ((uint16_t)0x0040) /**< @brief Error: Emergency input (overcurrent) */

1 reply

GMA
Technical Moderator
September 8, 2025

Hello @BY1,

Which boards are you using?
When connecting the Motor Pilot Tool, what was the first triggered error?
The second error, 0x40, is overcurrent (defined in the mc_type.h file). This error is due to the 90% Charge Boot Capacitor Duty parameter.

If you agree with the answer, please accept it by clicking on 'Accept as solution'.Best regards.GMA
BY1Author
Associate II
September 9, 2025

Sorry, my previous description was not detailed enough. Please let me rephrase it. I am using STM32G431CBT6. After downloading the foc control code generated by MCSDK6.4.0 to STM32G431CBT6, I connected the brushless DC motor and pressed the button. After that, Mci [M1]. State successfully changed from IDLE to OFFSET-CALIB and executed R3_2_TurnOnlowSides (pwmcHandle [M1], M1_CARGE_BOOT_CAP_SUT_CYCLES); Afterwards, the code will enter HardFault-Header and occasionally NMI_Handler. If I change the value of M1_CARGE_BOOT_CAP_SUT_CYCLES from the default 0 to (uint322-t) (0.6 * ((uint322-t) PWM-PERIOD_CYCLES/2U)), then Mci [M1]. State can successfully change from IDLE to RUN, but it will soon change to FAULTRA-OVER, and the value of MCI_CetCurrentFaults (&Mci [M1]) is 0x40, and the motor does not rotate. I tried to write my own code and directly use a 6-step square wave to control it. The motor can rotate, and my motor and Hall sensor should be working properly.

BY1Author
Associate II
September 9, 2025

I am not sure about the specific reason for entering HardFault-Hader and NMI_Handler, but I can provide a detailed description of the observed phenomenon. If the Mci [M1]. State is changed directly from IDLE to RUN after pressing the button, the program will not enter HardFault-Hader and NMI_Handler. Therefore, I suspect that the error was caused by modifying certain registers in the OFFSET-CALIB and CHARGE.BOOT.CAP states. Then I changed the Mci [M1]. State from IDLE directly to CHARGE.BOOT.CAP, and found that the error still occurred. However, by doing so, we can see the square wave of the ch pin. If we enter OFFSET-CALIB from IDLE and then enter CHARGE.BOOT.CAP, we can see the square wave of the ch pin., executed R3_2_TurnOnLowSides (pwmcHandle [M1], M1_CARGE_BOOT_CAP_SUT_CYCLES); If PWM is preloaded, no waveform can be seen, so it is possible that after modifying the PWM related registers, it entered HardFault Handler and NMI-Handler in a very short time (less than one PWM cycle)