cancel
Showing results for 
Search instead for 
Did you mean: 

STSPIN32G4 gets stuck in an infinite while loop inside R3_2_SwitchOffPWM() during the motor control

Raj6135
Associate II

I'm running into an issue where my STM32G4 gets stuck in an infinite while loop inside R3_2_SwitchOffPWM() during the motor control initialisation sequence, and I wanted to share it here in case others have encountered the same thing.

---

Hardware & Software
- Board: EVSPIN32G4
- Code generation tool: ST Motor Control Workbench v6.4.2
- No manual edits made to any generated files

---

What happens

During startup, MX_MotorControl_Init() is called from main(), which triggers MCboot() → FOC_Clear() → PWMC_SwitchOffPWM() → R3_2_SwitchOffPWM(). Inside that function, execution enters this loop and never exits:


/* wait for a new PWM period to flush last HF task */
LL_TIM_ClearFlag_UPDATE(TIMx);
while (LL_TIM_IsActiveFlag_UPDATE(TIMx) == 0u)
{}
LL_TIM_ClearFlag_UPDATE(TIMx);

(Project Files attached)

1 ACCEPTED SOLUTION

Accepted Solutions

Hello @Raj6135,

Does MCSDK_v6.4.2-Full folder present in ~/STM32Cube/Repository? If not, uninstall and reinstall MCSDK6.4.2.
Generate a new project (do not use a previously use directory).
Generated .ioc file should contain "ExtraMW.MotorControl.Root=MCSDK_v6.4.2-Full/MotorControl".

STM32CubeMX v6.17.0 is recommended for MCSDK6.4.2 (refer to MCSDK release note for more details).

If you agree with the answer, please accept it by clicking on 'Accept as solution'.
Best regards.
GMA

View solution in original post

3 REPLIES 3
GMA
ST Employee

Hello @Raj6135,

Project has been generated with MCSDK6.4.2, but on your ioc file "ExtraMW.MotorControl.Root=MCSDK_v5.4.8-Full/MotorControl" and in the project directory there is MCSDK_v5.4.8-Full.
Did you modify the wb2mx.properties file?

If you agree with the answer, please accept it by clicking on 'Accept as solution'.
Best regards.
GMA

Thank you for the reply, @GMA. I did not modify any project files; however, there are multiple versions installed on my computer (as listed in the attached image).

Raj6135_0-1777285177467.png

 

Hello @Raj6135,

Does MCSDK_v6.4.2-Full folder present in ~/STM32Cube/Repository? If not, uninstall and reinstall MCSDK6.4.2.
Generate a new project (do not use a previously use directory).
Generated .ioc file should contain "ExtraMW.MotorControl.Root=MCSDK_v6.4.2-Full/MotorControl".

STM32CubeMX v6.17.0 is recommended for MCSDK6.4.2 (refer to MCSDK release note for more details).

If you agree with the answer, please accept it by clicking on 'Accept as solution'.
Best regards.
GMA