STM32G4 Motor Control — How to pause Motor Control during application startup?
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 */
}
}