drivers: timer: nrf_rtc_timer: Add clearing of previous CC event
Added clearing of CC event which may occure due to previous CC value which was closed to current counter value. Fixed int_mask initialization. Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
This commit is contained in:
parent
acf1939a4c
commit
b417f68609
1 changed files with 3 additions and 2 deletions
|
@ -160,12 +160,11 @@ static void set_absolute_alarm(uint32_t chan, uint32_t abs_val)
|
||||||
uint32_t cc_val = abs_val & COUNTER_MAX;
|
uint32_t cc_val = abs_val & COUNTER_MAX;
|
||||||
uint32_t prev_cc = get_comparator(chan);
|
uint32_t prev_cc = get_comparator(chan);
|
||||||
|
|
||||||
|
|
||||||
do {
|
do {
|
||||||
now = counter();
|
now = counter();
|
||||||
|
|
||||||
/* Handle case when previous event may generate an event.
|
/* Handle case when previous event may generate an event.
|
||||||
* It is handled by setting CC to now (that's furtherst future),
|
* It is handled by setting CC to now (far in the future),
|
||||||
* in case previous event was set for next tick wait for half
|
* in case previous event was set for next tick wait for half
|
||||||
* LF tick and clear event that may have been generated.
|
* LF tick and clear event that may have been generated.
|
||||||
*/
|
*/
|
||||||
|
@ -174,6 +173,7 @@ static void set_absolute_alarm(uint32_t chan, uint32_t abs_val)
|
||||||
k_busy_wait(15);
|
k_busy_wait(15);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* If requested cc_val is in the past or next tick, set to 2
|
/* If requested cc_val is in the past or next tick, set to 2
|
||||||
* ticks from now. RTC may not generate event if CC is set for
|
* ticks from now. RTC may not generate event if CC is set for
|
||||||
* 1 tick from now.
|
* 1 tick from now.
|
||||||
|
@ -182,6 +182,7 @@ static void set_absolute_alarm(uint32_t chan, uint32_t abs_val)
|
||||||
cc_val = now + 2;
|
cc_val = now + 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
event_clear(chan);
|
||||||
event_enable(chan);
|
event_enable(chan);
|
||||||
set_comparator(chan, cc_val);
|
set_comparator(chan, cc_val);
|
||||||
now2 = counter();
|
now2 = counter();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue