drivers: timer: systick: fix off-by-one setting
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 non- tickless mode, we need to configure the LOAD value with CYC_PER_TICK - 1, in order to get an event every CYC_PER_TICK cycles. Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
This commit is contained in:
parent
04ef68b85a
commit
b1b4ec126d
1 changed files with 1 additions and 1 deletions
|
@ -102,7 +102,7 @@ void z_clock_isr(void *arg)
|
|||
int z_clock_driver_init(struct device *device)
|
||||
{
|
||||
NVIC_SetPriority(SysTick_IRQn, _IRQ_PRIO_OFFSET);
|
||||
last_load = CYC_PER_TICK;
|
||||
last_load = CYC_PER_TICK - 1;
|
||||
overflow_cyc = 0U;
|
||||
SysTick->LOAD = last_load;
|
||||
SysTick->VAL = 0; /* resets timer to last_load */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue