Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cpu/nrf5x_common/periph_timer: fix spurious IRQs [backport 2022.10] #18974

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions cpu/nrf5x_common/periph/timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,12 @@ int timer_set_absolute(tim_t tim, int chan, unsigned int value)

ctx[tim].flags |= (1 << chan);
dev(tim)->CC[chan] = value;

/* clear spurious IRQs */
dev(tim)->EVENTS_COMPARE[chan] = 0;
(void)dev(tim)->EVENTS_COMPARE[chan];

/* enable IRQ */
dev(tim)->INTENSET = (TIMER_INTENSET_COMPARE0_Msk << chan);

return 0;
Expand All @@ -126,6 +132,12 @@ int timer_set_periodic(tim_t tim, int chan, unsigned int value, uint8_t flags)
if (flags & TIM_FLAG_RESET_ON_SET) {
dev(tim)->TASKS_CLEAR = 1;
}

/* clear spurious IRQs */
dev(tim)->EVENTS_COMPARE[chan] = 0;
(void)dev(tim)->EVENTS_COMPARE[chan];

/* enable IRQ */
dev(tim)->INTENSET = (TIMER_INTENSET_COMPARE0_Msk << chan);

/* re-start timer */
Expand Down