cancel
Showing results for 
Search instead for 
Did you mean: 

STM32G4 Motor Control — How to pause Motor Control during application startup?

ElGuerrero91
Associate II

Hi ST Community,

During my application startup I am facing an issue where TIMx_UP_IRQHandler is constantly triggered while using HAL_Delay(). It seems that the Motor Control SDK is using TIM1 which periodically fires the TIM IRQ handler, interfering with my startup routine.

To verify this, I commented out MX_MotorControl_Init() in main.c and my startup routine completed successfully.

My startup routine must not be interrupted by the Motor Control tasks. Therefore I need to delay the Motor Control initialization until my startup is complete.

Is there an official API to temporarily disable Motor Control Tasks during startup and re-enable them once the application is ready? ( I would like to avoid shifting the MX_MotorControl_Init() function in my startup code)

 

int main(void)
{
...
  /* Initialize all configured peripherals */
...
  MX_MotorControl_Init();
  MX_IWDG_Init();
  MX_SPI2_Init();

  /* Initialize interrupts */
  MX_NVIC_Init();

  // Disable IWDG if core is halted
  __HAL_DBGMCU_FREEZE_IWDG();

  
  while (1)
  {
    // 3. Refresh (Feed) the dog periodically
    HAL_IWDG_Refresh(&hiwdg);

    CppMain_Loop(); //this is my periodically called routine
    /* USER CODE END WHILE */

    /* USER CODE BEGIN 3 */
  }
  /* USER CODE END 3 */
}



}
 
1 REPLY 1
GMA
ST Employee

Hello @ElGuerrero91,

Since MCSDK 6.4.0 version, after calling the MX_MotorControl_Init() and MX_NVIC_Init() functions, the current measurements are activated, and then the TIM interrupt request (IRQ) handler is triggered (see Current sampling chapter in the MCSDK user manual).
In MCSDK 6.3.2 version, the TIM IRQ associated with current measurement is enabled only when the motor is spinning.

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