drivers: timer: nrf: Fix premature timeouts

If timeout is being overwrite exactly when previous one is expiring
then hardware event was cleared correctly but interrupt was already
triggered. Interrupt routine was assuming that compare event is set
and proceed with that assumption. However, in that corner case when
compare event was overwritten and event was cleared, that was not the
case.

As the outcome, timeout could be triggered prematurely. Fixed by
clearing pending interrupt after handling previous compare value.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
This commit is contained in:
Krzysztof Chruscinski 2020-05-21 11:59:30 +02:00 committed by Carles Cufí
commit 699b717452

View file

@ -88,6 +88,11 @@ static void prevent_false_prev_evt(void)
k_busy_wait(15);
event_clear();
}
/* Clear interrupt that may have fired as we were setting the
* comparator.
*/
NVIC_ClearPendingIRQ(RTC1_IRQn);
}
/* If settings is next tick from now, function attempts to set next tick. If