mirror of
https://github.com/rtic-rs/rtic.git
synced 2025-12-16 12:55:23 +01:00
panic if STM32 clock prescaler value overflows
This commit is contained in:
parent
1104a12ca3
commit
b4a0c9057d
2 changed files with 7 additions and 2 deletions
|
|
@ -7,6 +7,9 @@ For each category, *Added*, *Changed*, *Fixed* add new entries at the top!
|
|||
|
||||
## Unreleased
|
||||
|
||||
### Changed
|
||||
- Panic if STM32 prescaler value would overflow
|
||||
|
||||
## v2.1.0 - 2025-06-22
|
||||
|
||||
### Changed
|
||||
|
|
|
|||
|
|
@ -238,8 +238,10 @@ macro_rules! make_timer {
|
|||
$timer.cr1().modify(|r| r.set_cen(false));
|
||||
|
||||
assert!((tim_clock_hz % timer_hz) == 0, "Unable to find suitable timer prescaler value!");
|
||||
let psc = tim_clock_hz / timer_hz - 1;
|
||||
$timer.psc().write(|r| r.set_psc(psc as u16));
|
||||
let Ok(psc) = u16::try_from(tim_clock_hz / timer_hz - 1) else {
|
||||
panic!("Clock prescaler overflowed!");
|
||||
};
|
||||
$timer.psc().write(|r| r.set_psc(psc));
|
||||
|
||||
// Enable full-period interrupt.
|
||||
$timer.dier().modify(|r| r.set_uie(true));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue