drivers: timer: systick: fix off-by-one setting in tickless mode
When the counter reaches zero, it reloads the value in SYST_RVR on the next clock edge. This means that if the LOAD value is N, the interrupt ("tick") is triggered every N+1 cycles. Therefore, when we operate in tickless mode, and we want to schedule the next timeout, we need to configure the LOAD value with last_load - 1, in order to get an event in last_load cycles. Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
This commit is contained in:
parent
b1b4ec126d
commit
a0a861bfd7
1 changed files with 1 additions and 1 deletions
|
@ -144,7 +144,7 @@ void z_clock_set_timeout(s32_t ticks, bool idle)
|
|||
last_load = delay - (cycle_count - announced_cycles);
|
||||
|
||||
overflow_cyc = 0U;
|
||||
SysTick->LOAD = last_load;
|
||||
SysTick->LOAD = last_load - 1;
|
||||
SysTick->VAL = 0; /* resets timer to last_load */
|
||||
|
||||
k_spin_unlock(&lock, key);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue