未验证 提交 ad397a63 编写于 作者: H HubretXie 提交者: GitHub

[bsp][stm32]修复硬件定时器bug

上级 aa52a30b
...@@ -228,6 +228,8 @@ static rt_err_t timer_start(rt_hwtimer_t *timer, rt_uint32_t t, rt_hwtimer_mode_ ...@@ -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; tim = (TIM_HandleTypeDef *)timer->parent.user_data;
/* set tim cnt */ /* set tim cnt */
__HAL_TIM_SET_COUNTER(tim, 0);
/* set tim arr */
__HAL_TIM_SET_AUTORELOAD(tim, t - 1); __HAL_TIM_SET_AUTORELOAD(tim, t - 1);
if (opmode == HWTIMER_MODE_ONESHOT) if (opmode == HWTIMER_MODE_ONESHOT)
...@@ -260,6 +262,9 @@ static void timer_stop(rt_hwtimer_t *timer) ...@@ -260,6 +262,9 @@ static void timer_stop(rt_hwtimer_t *timer)
/* stop timer */ /* stop timer */
HAL_TIM_Base_Stop_IT(tim); 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) static rt_err_t timer_ctrl(rt_hwtimer_t *timer, rt_uint32_t cmd, void *arg)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册