diff --git a/arch/arm64/src/common/arm64_arch_timer.c b/arch/arm64/src/common/arm64_arch_timer.c index 21fc07c3adc2b..ce7e4dda0269e 100644 --- a/arch/arm64/src/common/arm64_arch_timer.c +++ b/arch/arm64/src/common/arm64_arch_timer.c @@ -244,6 +244,7 @@ static int arm64_tick_start(struct oneshot_lowerhalf_s *lower, { struct arm64_oneshot_lowerhalf_s *priv = (struct arm64_oneshot_lowerhalf_s *)lower; + uint64_t next_cycle; DEBUGASSERT(priv != NULL && callback != NULL); @@ -252,10 +253,11 @@ static int arm64_tick_start(struct oneshot_lowerhalf_s *lower, priv->callback = callback; priv->arg = arg; - /* Set the timeout */ + next_cycle = + arm64_arch_timer_count() / priv->cycle_per_tick * priv->cycle_per_tick + + ticks * priv->cycle_per_tick; - arm64_arch_timer_set_compare(arm64_arch_timer_count() + - priv->cycle_per_tick * ticks); + arm64_arch_timer_set_compare(next_cycle); arm64_arch_timer_set_irq_mask(false); return OK; @@ -418,4 +420,4 @@ void arm64_arch_timer_secondary_init() arm64_arch_timer_enable(true); #endif } -#endif \ No newline at end of file +#endif