Skip to content

Commit

Permalink
set a long reload in clear_compare_flag()
Browse files Browse the repository at this point in the history
In extend=true, the reload interrupt is not disabled (for overflow
detection), the previous `set_compare()` may have been called with a
short interval, then, if the queue is empty, the reload interrupt would
fire at very short interval.
  • Loading branch information
jordens committed Feb 4, 2022
1 parent 23be86d commit 1c8dec5
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,11 @@ impl<const TIMER_HZ: u32> Monotonic for DwtSystick<TIMER_HZ> {

#[inline(always)]
fn clear_compare_flag(&mut self) {
// NOOP with SysTick interrupt
// Set a long reload in case `set_compare()` is not called again.
#[cfg(feature = "extend")]
self.systick.set_reload(0xff_ffff);
#[cfg(feature = "extend")]
self.systick.clear_current();
}

#[cfg(feature = "extend")]
Expand Down

0 comments on commit 1c8dec5

Please sign in to comment.