From ad397a63a84e909b4b292c8589388661ada2bd07 Mon Sep 17 00:00:00 2001 From: HubretXie Date: Thu, 12 Dec 2019 14:56:40 +0800 Subject: [PATCH] =?UTF-8?q?[bsp][stm32]=E4=BF=AE=E5=A4=8D=E7=A1=AC?= =?UTF-8?q?=E4=BB=B6=E5=AE=9A=E6=97=B6=E5=99=A8bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bsp/stm32/libraries/HAL_Drivers/drv_hwtimer.c | 5 +++++ 1 file changed, 5 insertions(+) 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)