Skip to content

Commit 5b485ae

Browse files
committed
panic if STM32 clock prescaler value overflows
1 parent 42ebfe5 commit 5b485ae

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

rtic-monotonics/src/stm32.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,8 +238,8 @@ macro_rules! make_timer {
238238
$timer.cr1().modify(|r| r.set_cen(false));
239239

240240
assert!((tim_clock_hz % timer_hz) == 0, "Unable to find suitable timer prescaler value!");
241-
let psc = tim_clock_hz / timer_hz - 1;
242-
$timer.psc().write(|r| r.set_psc(psc as u16));
241+
let psc = u16::try_from(tim_clock_hz / timer_hz - 1).expect("Clock prescaler overflowed!");
242+
$timer.psc().write(|r| r.set_psc(psc));
243243

244244
// Enable full-period interrupt.
245245
$timer.dier().modify(|r| r.set_uie(true));

0 commit comments

Comments
 (0)