diff options
| -rw-r--r-- | embassy-stm32/src/rcc/f3.rs | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/embassy-stm32/src/rcc/f3.rs b/embassy-stm32/src/rcc/f3.rs index ababc4f90..5a7351444 100644 --- a/embassy-stm32/src/rcc/f3.rs +++ b/embassy-stm32/src/rcc/f3.rs | |||
| @@ -93,7 +93,10 @@ pub(crate) unsafe fn init(config: Config) { | |||
| 93 | assert!(pclk2 <= 72_000_000); | 93 | assert!(pclk2 <= 72_000_000); |
| 94 | 94 | ||
| 95 | // Set latency based on HCLK frquency | 95 | // Set latency based on HCLK frquency |
| 96 | FLASH.acr().write(|w| { | 96 | // RM0316: "The prefetch buffer must be kept on when using a prescaler |
| 97 | // different from 1 on the AHB clock.", "Half-cycle access cannot be | ||
| 98 | // used when there is a prescaler different from 1 on the AHB clock" | ||
| 99 | FLASH.acr().modify(|w| { | ||
| 97 | w.set_latency(if hclk <= 24_000_000 { | 100 | w.set_latency(if hclk <= 24_000_000 { |
| 98 | Latency::WS0 | 101 | Latency::WS0 |
| 99 | } else if hclk <= 48_000_000 { | 102 | } else if hclk <= 48_000_000 { |
| @@ -101,6 +104,10 @@ pub(crate) unsafe fn init(config: Config) { | |||
| 101 | } else { | 104 | } else { |
| 102 | Latency::WS2 | 105 | Latency::WS2 |
| 103 | }); | 106 | }); |
| 107 | if hpre_div != 1 { | ||
| 108 | w.set_hlfcya(false); | ||
| 109 | w.set_prftbe(true); | ||
| 110 | } | ||
| 104 | }); | 111 | }); |
| 105 | 112 | ||
| 106 | // Enable HSE | 113 | // Enable HSE |
