Skip to content

Commit eb0cbb4

Browse files
ananglcarlescufi
authored andcommitted
drivers: nrf_rtc_timer: Correct initial timeout value
Values to be set to the comparator need to be specified in RTC cycles, not ticks, so the initial value used in the tickless mode needs to be MAX_CYCLES, otherwise when CONFIG_SYS_CLOCK_TICKS_PER_SEC is set to a value less then the RTC frequency, the initially configured timeout will be unnecessarily shorter. On the occassion, remove also the call to counter() when setting the initial timeout value in non-tickless mode. RTC is cleared a few lines above, so at this point it will most likely be 0, and even if it was not, compare_set() would properly handle a target time value that had already passed. Signed-off-by: Andrzej Głąbek <[email protected]>
1 parent 3ffaaa9 commit eb0cbb4

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/timer/nrf_rtc_timer.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -670,7 +670,7 @@ static int sys_clock_driver_init(const struct device *dev)
670670
}
671671

672672
uint32_t initial_timeout = IS_ENABLED(CONFIG_TICKLESS_KERNEL) ?
673-
MAX_TICKS : (counter() + CYC_PER_TICK);
673+
MAX_CYCLES : CYC_PER_TICK;
674674

675675
compare_set(0, initial_timeout, sys_clock_timeout_handler, NULL);
676676

0 commit comments

Comments
 (0)