Skip to content

Commit 9d3b308

Browse files
ABOSTMfpistm
authored andcommitted
HardwareTimer: pause() need to call HAL API to restore HAL state
Due to HAL Cube update (ex: for STM32L4 sha1 f41f10e) it is now required to stop timer with HAL API otherwise HAL state is not restored to HAL_TIM_STATE_READY, and it is not possible to resume() a HardwareTimer after a pause(). Nevertheless it is not sufficient to guarantee that timer is stopped specially if some channels are still running. So it is also necessary to keep also the call to LL_TIM_DisableCounter() Signed-off-by: Alexandre Bourdiol <[email protected]>
1 parent 8c34ed0 commit 9d3b308

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

cores/arduino/HardwareTimer.cpp

+5-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,11 @@ void HardwareTimer::pause()
108108
__HAL_TIM_DISABLE_IT(&(_timerObj.handle), TIM_IT_CC3);
109109
__HAL_TIM_DISABLE_IT(&(_timerObj.handle), TIM_IT_CC4);
110110

111-
// Disable timer unconditionally
111+
// Stop timer. Required to restore HAL State: HAL_TIM_STATE_READY
112+
HAL_TIM_Base_Stop(&(_timerObj.handle));
113+
114+
/* Disable timer unconditionally. Required to guarantee timer is stopped,
115+
* even if some channels are still running */
112116
LL_TIM_DisableCounter(_timerObj.handle.Instance);
113117

114118
#if defined(TIM_CHANNEL_STATE_SET_ALL)

0 commit comments

Comments
 (0)