diff --git a/components/drivers/hwtimer/hwtimer.c b/components/drivers/hwtimer/hwtimer.c index bbe50aa2f7..066c5f6f6c 100644 --- a/components/drivers/hwtimer/hwtimer.c +++ b/components/drivers/hwtimer/hwtimer.c @@ -192,14 +192,15 @@ static rt_size_t rt_hwtimer_write(struct rt_device *dev, rt_off_t pos, const voi if (size != sizeof(rt_hwtimerval_t)) return 0; - if ((timer->cycles <= 1) && (timer->mode == HWTIMER_MODE_ONESHOT)) - { - opm = HWTIMER_MODE_ONESHOT; - } timer->ops->stop(timer); timer->overflow = 0; t = timeout_calc(timer, (rt_hwtimerval_t*)buffer); + if ((timer->cycles <= 1) && (timer->mode == HWTIMER_MODE_ONESHOT)) + { + opm = HWTIMER_MODE_ONESHOT; + } + if (timer->ops->start(timer, t, opm) != RT_EOK) size = 0;