Skip to content

Commit 29956b0

Browse files
khayash1nashif
authored andcommitted
drivers: arm_arch_timer: Move timer enablement after comparison value set
The timer is enabled before comparison value is set, which can lead to unexpected behavior if the registers contain uninitialized values. Should call arm_arch_timer_enable() after arm_arch_timer_set_compare(). Signed-off-by: Kunihiko Hayashi <[email protected]>
1 parent 4f61e65 commit 29956b0

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/timer/arm_arch_timer.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,10 +236,10 @@ static int sys_clock_driver_init(void)
236236
cyc_per_tick = sys_clock_hw_cycles_per_sec() / CONFIG_SYS_CLOCK_TICKS_PER_SEC;
237237
cycles_max = CYCLES_MAX_5;
238238
#endif
239-
arm_arch_timer_enable(true);
240239
last_tick = arm_arch_timer_count() / CYC_PER_TICK;
241240
last_cycle = last_tick * CYC_PER_TICK;
242241
arm_arch_timer_set_compare(last_cycle + CYC_PER_TICK);
242+
arm_arch_timer_enable(true);
243243
irq_enable(ARM_ARCH_TIMER_IRQ);
244244
arm_arch_timer_set_irq_mask(false);
245245

0 commit comments

Comments
 (0)