diff options
| author | Finomnis <Finomnis@users.noreply.github.com> | 2024-07-05 18:19:51 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-07-05 16:19:51 +0000 |
| commit | 5cafe9dd0bfc24b4243cc5e5d6be6b7c7556f3a3 (patch) | |
| tree | 8ac2f80263c1cd82e1dbc62dd3153ae66d9692d0 /rtic-monotonics/src/stm32.rs | |
| parent | 624f643a976fc0676750de9c22d789115cba21c1 (diff) | |
Fix STM32 Monotonic for peripherals with only two Clock Compare modules (#960)
* Update dependencies of stm32g0 timer example
* Replace obsolete probe-run with probe-rs run
* Modify stm32 monotonic to work with timers that have only 2 compare modules
* Add changelog
* Fix typo
Diffstat (limited to 'rtic-monotonics/src/stm32.rs')
| -rw-r--r-- | rtic-monotonics/src/stm32.rs | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/rtic-monotonics/src/stm32.rs b/rtic-monotonics/src/stm32.rs index 6b3e4c9..bc24b83 100644 --- a/rtic-monotonics/src/stm32.rs +++ b/rtic-monotonics/src/stm32.rs @@ -240,8 +240,8 @@ macro_rules! make_timer { $timer.dier().modify(|r| r.set_uie(true)); // Configure and enable half-period interrupt - $timer.ccr(2).write(|r| r.set_ccr(($bits::MAX - ($bits::MAX >> 1)).into())); - $timer.dier().modify(|r| r.set_ccie(2, 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)); @@ -282,7 +282,7 @@ macro_rules! make_timer { let now = Self::now(); // Since the timer may or may not overflow based on the requested compare val, we check how many ticks are left. - // `wrapping_sup` takes care of the u64 integer overflow special case. + // `wrapping_sub` takes care of the u64 integer overflow special case. let val = if instant.wrapping_sub(now) <= ($bits::MAX as u64) { instant as $bits } else { @@ -317,8 +317,8 @@ macro_rules! make_timer { assert!(prev % 2 == 1, "Monotonic must have missed an interrupt!"); } // Half period - if $timer.sr().read().ccif(2) { - $timer.sr().modify(|r| r.set_ccif(2, 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!"); } |
