@@ -138,15 +138,30 @@ void SystemInit (void)
138138 SCB -> CPACR |= ((3UL << (10 * 2 ))|(3UL << (11 * 2 ))); /* set CP10 and CP11 Full Access */
139139 #endif
140140 /* Reset the RCC clock configuration to the default reset state ------------*/
141+
142+ /* Increasing the CPU frequency */
143+ if (FLASH_LATENCY_DEFAULT > (READ_BIT ((FLASH -> ACR ), FLASH_ACR_LATENCY )))
144+ {
145+ /* Program the new number of wait states to the LATENCY bits in the FLASH_ACR register */
146+ MODIFY_REG (FLASH -> ACR , FLASH_ACR_LATENCY , (uint32_t )(FLASH_LATENCY_DEFAULT ));
147+ }
148+
141149 /* Set HSION bit */
142150 RCC -> CR |= RCC_CR_HSION ;
143151
144152 /* Reset CFGR register */
145153 RCC -> CFGR = 0x00000000 ;
146154
147- /* Reset HSEON, CSSON , CSION,RC48ON , CSIKERON PLL1ON, PLL2ON and PLL3ON bits */
155+ /* Reset HSEON, HSECSSON , CSION, HSI48ON , CSIKERON, PLL1ON, PLL2ON and PLL3ON bits */
148156 RCC -> CR &= 0xEAF6ED7FU ;
149157
158+ /* Decreasing the number of wait states because of lower CPU frequency */
159+ if (FLASH_LATENCY_DEFAULT < (READ_BIT ((FLASH -> ACR ), FLASH_ACR_LATENCY )))
160+ {
161+ /* Program the new number of wait states to the LATENCY bits in the FLASH_ACR register */
162+ MODIFY_REG (FLASH -> ACR , FLASH_ACR_LATENCY , (uint32_t )(FLASH_LATENCY_DEFAULT ));
163+ }
164+
150165#if defined(D3_SRAM_BASE )
151166 /* Reset D1CFGR register */
152167 RCC -> D1CFGR = 0x00000000 ;
@@ -167,23 +182,23 @@ void SystemInit (void)
167182 RCC -> SRDCFGR = 0x00000000 ;
168183#endif
169184 /* Reset PLLCKSELR register */
170- RCC -> PLLCKSELR = 0x00000000 ;
185+ RCC -> PLLCKSELR = 0x02020200 ;
171186
172187 /* Reset PLLCFGR register */
173- RCC -> PLLCFGR = 0x00000000 ;
188+ RCC -> PLLCFGR = 0x01FF0000 ;
174189 /* Reset PLL1DIVR register */
175- RCC -> PLL1DIVR = 0x00000000 ;
190+ RCC -> PLL1DIVR = 0x01010280 ;
176191 /* Reset PLL1FRACR register */
177192 RCC -> PLL1FRACR = 0x00000000 ;
178193
179194 /* Reset PLL2DIVR register */
180- RCC -> PLL2DIVR = 0x00000000 ;
195+ RCC -> PLL2DIVR = 0x01010280 ;
181196
182197 /* Reset PLL2FRACR register */
183198
184199 RCC -> PLL2FRACR = 0x00000000 ;
185200 /* Reset PLL3DIVR register */
186- RCC -> PLL3DIVR = 0x00000000 ;
201+ RCC -> PLL3DIVR = 0x01010280 ;
187202
188203 /* Reset PLL3FRACR register */
189204 RCC -> PLL3FRACR = 0x00000000 ;
@@ -221,13 +236,20 @@ void SystemInit (void)
221236#if defined(DUAL_CORE ) && defined(CORE_CM4 )
222237 /* Configure the Vector Table location add offset address for cortex-M4 ------------------*/
223238#ifdef VECT_TAB_SRAM
224- SCB -> VTOR = D2_AHBSRAM_BASE | VECT_TAB_OFFSET ; /* Vector Table Relocation in Internal SRAM */
239+ SCB -> VTOR = D2_AXISRAM_BASE | VECT_TAB_OFFSET ; /* Vector Table Relocation in Internal SRAM */
225240#else
226241 SCB -> VTOR = FLASH_BANK2_BASE | VECT_TAB_OFFSET ; /* Vector Table Relocation in Internal FLASH */
227242#endif /* VECT_TAB_SRAM */
228243
229244#else
230245
246+ /*
247+ * Disable the FMC bank1 (enabled after reset).
248+ * This, prevents CPU speculation access on this bank which blocks the use of FMC during
249+ * 24us. During this time the others FMC master (such as LTDC) cannot use it!
250+ */
251+ FMC_Bank1_R -> BTCR [0 ] = 0x000030D2 ;
252+
231253 /* Configure the Vector Table location add offset address for cortex-M7 ------------------*/
232254#ifdef VECT_TAB_SRAM
233255 SCB -> VTOR = D1_AXISRAM_BASE | VECT_TAB_OFFSET ; /* Vector Table Relocation in Internal AXI-RAM */
0 commit comments