Skip to content

Commit

Permalink
Make initialization more deterministic
Browse files Browse the repository at this point in the history
  • Loading branch information
Finomnis committed Oct 23, 2024
1 parent 185bf36 commit 0ff7023
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions rtic-monotonics/src/stm32.rs
Original file line number Diff line number Diff line change
Expand Up @@ -246,11 +246,16 @@ macro_rules! make_timer {
// Trigger an update event to load the prescaler value to the clock.
$timer.egr().write(|r| r.set_ug(true));

// Clear timer value so it is known that we are at the first half period
$timer.cnt().write(|r| r.set_cnt(1));

// The above line raises an update event which will indicate that the timer is already finished.
// Since this is not the case, it should be cleared.
$timer.sr().write(|r| {
r.0 = !0;
r.set_uif(false);
r.set_ccif(0, false);
r.set_ccif(1, false);
});

$tq.initialize(Self {});
Expand Down

0 comments on commit 0ff7023

Please sign in to comment.