Skip to content

Commit

Permalink
Use CCR0 instead of CCR1
Browse files Browse the repository at this point in the history
  • Loading branch information
great-houk committed Jul 5, 2024
1 parent b474fee commit ed6c1e8
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions rtic-monotonics/src/stm32.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,8 +240,8 @@ macro_rules! make_timer {
$timer.dier().modify(|r| r.set_uie(true));

// Configure and enable half-period interrupt
$timer.ccr(1).write(|r| r.set_ccr(($bits::MAX - ($bits::MAX >> 1)).into()));
$timer.dier().modify(|r| r.set_ccie(1, true));
$timer.ccr(0).write(|r| r.set_ccr(($bits::MAX - ($bits::MAX >> 1)).into()));
$timer.dier().modify(|r| r.set_ccie(0, true));

// Trigger an update event to load the prescaler value to the clock.
$timer.egr().write(|r| r.set_ug(true));
Expand Down Expand Up @@ -290,7 +290,7 @@ macro_rules! make_timer {
0
};

$timer.ccr(1).write(|r| r.set_ccr(val.into()));
$timer.ccr(0).write(|r| r.set_ccr(val.into()));
}

fn clear_compare_flag() {
Expand All @@ -309,8 +309,8 @@ macro_rules! make_timer {
assert!(prev % 2 == 1, "Monotonic must have missed an interrupt!");
}
// Half period
if $timer.sr().read().ccif(1) {
$timer.sr().modify(|r| r.set_ccif(1, false));
if $timer.sr().read().ccif(0) {
$timer.sr().modify(|r| r.set_ccif(0, false));
let prev = $overflow.fetch_add(1, Ordering::Relaxed);
assert!(prev % 2 == 0, "Monotonic must have missed an interrupt!");
}
Expand Down

0 comments on commit ed6c1e8

Please sign in to comment.