diff options
| author | Bernard Xiong <[email protected]> | 2019-12-13 07:17:27 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2019-12-13 07:17:27 +0800 |
| commit | 4b27738264a5119244651c6924e84b11ad5fb98e (patch) | |
| tree | bd43eef0d1f5a96feac4ebdac17776e7053e014a /bsp/stm32 | |
| parent | 44123368a9469e550f7870203177540f162bda1d (diff) | |
| parent | ad397a63a84e909b4b292c8589388661ada2bd07 (diff) | |
Merge pull request #3260 from HubertXie/master
[bsp][stm32] fix the hardware timer issue
Diffstat (limited to 'bsp/stm32')
| -rw-r--r-- | bsp/stm32/libraries/HAL_Drivers/drv_hwtimer.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/bsp/stm32/libraries/HAL_Drivers/drv_hwtimer.c b/bsp/stm32/libraries/HAL_Drivers/drv_hwtimer.c index 52fa5c84fa..dfc96ae26b 100644 --- a/bsp/stm32/libraries/HAL_Drivers/drv_hwtimer.c +++ b/bsp/stm32/libraries/HAL_Drivers/drv_hwtimer.c @@ -228,6 +228,8 @@ static rt_err_t timer_start(rt_hwtimer_t *timer, rt_uint32_t t, rt_hwtimer_mode_ tim = (TIM_HandleTypeDef *)timer->parent.user_data; /* set tim cnt */ + __HAL_TIM_SET_COUNTER(tim, 0); + /* set tim arr */ __HAL_TIM_SET_AUTORELOAD(tim, t - 1); if (opmode == HWTIMER_MODE_ONESHOT) @@ -260,6 +262,9 @@ static void timer_stop(rt_hwtimer_t *timer) /* stop timer */ HAL_TIM_Base_Stop_IT(tim); + + /* set tim cnt */ + __HAL_TIM_SET_COUNTER(tim, 0); } static rt_err_t timer_ctrl(rt_hwtimer_t *timer, rt_uint32_t cmd, void *arg) |
