Skip to content

Commit

Permalink
fix(v0): flash latency when init rcc
Browse files Browse the repository at this point in the history
  • Loading branch information
andelf committed May 5, 2024
1 parent 8e7b9da commit c9217c1
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/rcc/v0.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ use crate::pac::rcc::vals::{Hpre as AHBPrescaler, Pllsrc as PllSource, Ppre as A
use crate::pac::{AFIO, FLASH, RCC};
use crate::time::Hertz;

const HSI_FREQUENCY: Hertz = Hertz(24_000_000);
pub const HSI_FREQUENCY: Hertz = Hertz(24_000_000);

const LSI_FREQUENCY: Hertz = Hertz(128_000);
pub const LSI_FREQUENCY: Hertz = Hertz(128_000);

#[derive(Clone, Copy, PartialEq, Debug)]
pub enum HseMode {
Expand Down Expand Up @@ -126,6 +126,10 @@ pub(crate) unsafe fn init(config: Config) {
_ => unreachable!(),
};

if sysclk >= 24_000_000 {
FLASH.actlr().modify(|w| w.set_latency(0b01)); // 1 等待(24MHz<HCLK≤48MHz)
}

RCC.cfgr0().modify(|w| {
w.set_hpre(config.ahb_pre);
w.set_ppre2(config.apb2_pre); // FIXME: this is undocumented, only for ADC2?
Expand Down

0 comments on commit c9217c1

Please sign in to comment.