Skip to content

Commit 1f3ded7

Browse files
committed
Enable the voltage regulator overdrive
for MCUs that support overclocking to 180 MHz. The reference manual states that this can be done while waiting for PLL lock. Fixes #196
1 parent d5f244c commit 1f3ded7

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
1515
- Move SDIO card power handling to its own function.
1616
- [breaking-change] Add a 2 ms delay after changing SDIO card power setting.
1717
- [breaking-change] Changed sdio::{read, write}_block buf argument to &[u8; 512].
18+
- Voltage regulator overdrive is enabled where supported and required for selected HCLK.
1819

1920
### Added
2021

src/rcc.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,27 @@ impl CFGR {
349349
// Enable PLL
350350
rcc.cr.modify(|_, w| w.pllon().set_bit());
351351

352+
// Enable voltage regulator overdrive if HCLK is above the limit
353+
#[cfg(any(
354+
feature = "stm32f427",
355+
feature = "stm32f429",
356+
feature = "stm32f437",
357+
feature = "stm32f439",
358+
feature = "stm32f446",
359+
feature = "stm32f469",
360+
feature = "stm32f479"
361+
))]
362+
if hclk > 168_000_000 {
363+
// Enable clock for PWR peripheral
364+
rcc.apb1enr.modify(|_, w| w.pwren().set_bit());
365+
366+
let pwr = unsafe { &*crate::stm32::PWR::ptr() };
367+
pwr.cr.modify(|_, w| w.oden().set_bit());
368+
while pwr.csr.read().odrdy().bit_is_clear() {}
369+
pwr.cr.modify(|_, w| w.odswen().set_bit());
370+
while pwr.csr.read().odswrdy().bit_is_clear() {}
371+
}
372+
352373
// Wait for PLL to stabilise
353374
while rcc.cr.read().pllrdy().bit_is_clear() {}
354375
}

0 commit comments

Comments
 (0)