aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRalf <[email protected]>2022-05-11 20:54:09 +0200
committerRalf <[email protected]>2022-05-12 09:09:39 +0200
commit1a216958ac121befa7da6912db307516d1ddcb07 (patch)
treef39e32f35d2bc4842f79b50a566b071f5bc38779
parentf4677469f9e9fc7bdc24577d9111636b4de2df46 (diff)
stm32/rcc: Set flash prefetch buffer and half cycle access according to AHB clock prescaler
-rw-r--r--embassy-stm32/src/rcc/f3.rs9
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