STM32CubeU5
STM32CubeU5 copied to clipboard
stm32u5xx_hal_timebase_tim_template.c: HAL_InitTick() initialization sequence error
In HAL_InitTick() https://github.com/STMicroelectronics/STM32CubeU5/blob/0eedae3d2a7997a2b5fbfdb57f54c7201e0827c8/Drivers/STM32U5xx_HAL_Driver/Src/stm32u5xx_hal_timebase_tim_template.c#L114-L140
the initialization sequence is incorrect:
- when using callbacks, the registration must be prior to starting the timer
- the interrupt should not be enabled if there is an initialization error
Suggested sequence:
Status = HAL_TIM_Base_Init(&TimHandle);
if (Status == HAL_OK)
{
#if (USE_HAL_TIM_REGISTER_CALLBACKS == 1U)
HAL_TIM_RegisterCallback(&TimHandle, HAL_TIM_PERIOD_ELAPSED_CB_ID, TimeBase_TIM_PeriodElapsedCallback);
#endif /* USE_HAL_TIM_REGISTER_CALLBACKS */
/* Start the TIM time Base generation in interrupt mode */
Status = HAL_TIM_Base_Start_IT(&TimHandle);
if (Status == HAL_OK)
{
if (TickPriority < (1UL << __NVIC_PRIO_BITS))
{
/* Enable the TIM6 global Interrupt */
HAL_NVIC_SetPriority(TIM6_IRQn, TickPriority, 0);
HAL_NVIC_EnableIRQ(TIM6_IRQn);
uwTickPrio = TickPriority;
}
else
{
Status = HAL_ERROR;
}
}
}
/* Return function Status */
return Status;
ST Internal Reference: 122898
Hi @a-wilhelm,
Thank you for your contribution. This issue has been fixed in the frame of version v1.2.0 of the STM32CubeU5. Please allow me then to close this thread.
With regards,