Skip to content

Commit 3a6c786

Browse files
nordic-krchgalak
authored andcommitted
drivers: counter: nrfx_rtc: Fix lack of interrupt when CC=0
According to documentation Compare event will not be triggered if CC=0 and CLEAR task is set. Added handling of that situation. Signed-off-by: Krzysztof Chruscinski <[email protected]>
1 parent 431c450 commit 3a6c786

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

drivers/counter/counter_nrfx_rtc.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,15 @@ static int counter_nrfx_set_alarm(struct device *dev, u8_t chan_id,
9999
nrfx_config->ch_data[chan_id].callback = alarm_cfg->callback;
100100
nrfx_config->ch_data[chan_id].user_data = alarm_cfg->user_data;
101101

102+
if ((cc_val == 0) &&
103+
(get_dev_data(dev)->top != counter_get_max_top_value(dev))) {
104+
/* From Product Specification: If a CC register value is 0 when
105+
* a CLEAR task is set, this will not trigger a COMPARE event.
106+
*/
107+
LOG_INST_INF(nrfx_config->log,
108+
"Attempt to set CC to 0, delayed to 1.");
109+
cc_val++;
110+
}
102111
nrfx_rtc_cc_set(rtc, ID_TO_CC(chan_id), cc_val, true);
103112

104113
return 0;

0 commit comments

Comments
 (0)