2021-10-20 06:13 AM
While developing my application I ran into the problem that the state of my timers working in "One pulse mode" (configured used STM32CubeMX with HAL libraries) where getting locked in the "HAL_TIM_STATE_BUSY" state after the "HAL_TIM_PeriodElapsedCallback" was executed. Trying to start the timer(s) again to generate a pulse once again didn't work anymore because the "HAL_TIM_Base_Start_IT" returns "HAL_ERROR". I was able to solve this by removing the check and setting of the state as shownin the screenshot in attachment. Is this a known issue and is there a better/correct way to solve this?
Thanks in advance.
Solved! Go to Solution.
2021-10-20 06:36 AM
Seems like the state is set to busy during HAL_TIM_Base_Start_IT and never set to ready after that:
Setting the state to busy is a recent change to the library. Here's an old version which doesn't do the check:
Instead of modifying the HAL source, perhaps just do this after the HAL_TIM_Base_Start_IT call:
htim->State = HAL_TIM_STATE_READY;
Or call HAL_TIM_Base_Stop_IT during the period elapsed callback, which will reset the state to ready:
2021-10-20 06:36 AM
Seems like the state is set to busy during HAL_TIM_Base_Start_IT and never set to ready after that:
Setting the state to busy is a recent change to the library. Here's an old version which doesn't do the check:
Instead of modifying the HAL source, perhaps just do this after the HAL_TIM_Base_Start_IT call:
htim->State = HAL_TIM_STATE_READY;
Or call HAL_TIM_Base_Stop_IT during the period elapsed callback, which will reset the state to ready:
2021-10-20 06:42 AM
Thank you for your reply and suggestions.