@@ -182,13 +182,9 @@ WEAK void SystemClock_Config(void)
182182 /* * Initializes the RCC Oscillators according to the specified parameters
183183 * in the RCC_OscInitTypeDef structure.
184184 */
185- RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI | RCC_OSCILLATORTYPE_HSE
186- | RCC_OSCILLATORTYPE_LSE ;
187- RCC_OscInitStruct.HSEState = RCC_HSE_BYPASS_DIGITAL ;
185+ RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE | RCC_OSCILLATORTYPE_LSE ;
186+ RCC_OscInitStruct.HSEState = RCC_HSE_BYPASS ;
188187 RCC_OscInitStruct.LSEState = RCC_LSE_ON ;
189- RCC_OscInitStruct.HSIState = RCC_HSI_ON ;
190- RCC_OscInitStruct.HSIDiv = RCC_HSI_DIV1 ;
191- RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT ;
192188 RCC_OscInitStruct.PLL .PLLState = RCC_PLL_ON ;
193189 RCC_OscInitStruct.PLL .PLLSource = RCC_PLL1_SOURCE_HSE ;
194190 RCC_OscInitStruct.PLL .PLLM = 4 ;
@@ -199,6 +195,7 @@ WEAK void SystemClock_Config(void)
199195 RCC_OscInitStruct.PLL .PLLRGE = RCC_PLL1_VCIRANGE_1 ;
200196 RCC_OscInitStruct.PLL .PLLVCOSEL = RCC_PLL1_VCORANGE_WIDE ;
201197 RCC_OscInitStruct.PLL .PLLFRACN = 0 ;
198+
202199 if (HAL_RCC_OscConfig (&RCC_OscInitStruct) != HAL_OK ) {
203200 Error_Handler ();
204201 }
@@ -221,22 +218,26 @@ WEAK void SystemClock_Config(void)
221218 /* * Initializes the peripherals clock
222219 */
223220 PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_ADCDAC | RCC_PERIPHCLK_LPUART1
224- | RCC_PERIPHCLK_OSPI | RCC_PERIPHCLK_SDMMC1
225221 | RCC_PERIPHCLK_USB ;
226- PeriphClkInitStruct.AdcDacClockSelection = RCC_ADCDACCLKSOURCE_HCLK ;
222+ PeriphClkInitStruct.AdcDacClockSelection = RCC_ADCDACCLKSOURCE_PLL2R ;
223+ PeriphClkInitStruct.Lpuart1ClockSelection = RCC_LPUART1CLKSOURCE_PCLK3 ;
224+ PeriphClkInitStruct.OspiClockSelection = RCC_OSPICLKSOURCE_HCLK ;
225+ PeriphClkInitStruct.Sdmmc1ClockSelection = RCC_SDMMC1CLKSOURCE_PLL1Q ;
226+ PeriphClkInitStruct.UsbClockSelection = RCC_USBCLKSOURCE_PLL3Q ;
227+
227228 PeriphClkInitStruct.PLL2 .PLL2Source = RCC_PLL2_SOURCE_HSE ;
228229 PeriphClkInitStruct.PLL2 .PLL2M = 2 ;
229- PeriphClkInitStruct.PLL2 .PLL2N = 128 ;
230+ PeriphClkInitStruct.PLL2 .PLL2N = 125 ;
230231 PeriphClkInitStruct.PLL2 .PLL2P = 2 ;
231- PeriphClkInitStruct.PLL2 .PLL2Q = 16 ;
232- PeriphClkInitStruct.PLL2 .PLL2R = 2 ;
232+ PeriphClkInitStruct.PLL2 .PLL2Q = 15 ;
233+ PeriphClkInitStruct.PLL2 .PLL2R = 4 ;
233234 PeriphClkInitStruct.PLL2 .PLL2RGE = RCC_PLL2_VCIRANGE_2 ;
234235 PeriphClkInitStruct.PLL2 .PLL2VCOSEL = RCC_PLL2_VCORANGE_WIDE ;
235236 PeriphClkInitStruct.PLL2 .PLL2FRACN = 0 ;
236- PeriphClkInitStruct.PLL2 .PLL2ClockOut = RCC_PLL2_DIVQ ;
237+ PeriphClkInitStruct.PLL2 .PLL2ClockOut = RCC_PLL2_DIVQ | RCC_PLL2_DIVR ;
237238 PeriphClkInitStruct.Lpuart1ClockSelection = RCC_LPUART1CLKSOURCE_PLL2Q ;
238- PeriphClkInitStruct.OspiClockSelection = RCC_OSPICLKSOURCE_HCLK ;
239- PeriphClkInitStruct. Sdmmc1ClockSelection = RCC_SDMMC1CLKSOURCE_PLL1Q ;
239+ PeriphClkInitStruct.AdcDacClockSelection = RCC_ADCDACCLKSOURCE_PLL2R ;
240+
240241 PeriphClkInitStruct.PLL3 .PLL3Source = RCC_PLL3_SOURCE_HSE ;
241242 PeriphClkInitStruct.PLL3 .PLL3M = 2 ;
242243 PeriphClkInitStruct.PLL3 .PLL3N = 96 ;
@@ -248,6 +249,7 @@ WEAK void SystemClock_Config(void)
248249 PeriphClkInitStruct.PLL3 .PLL3FRACN = 0 ;
249250 PeriphClkInitStruct.PLL3 .PLL3ClockOut = RCC_PLL3_DIVQ ;
250251 PeriphClkInitStruct.UsbClockSelection = RCC_USBCLKSOURCE_PLL3Q ;
252+
251253 if (HAL_RCCEx_PeriphCLKConfig (&PeriphClkInitStruct) != HAL_OK ) {
252254 Error_Handler ();
253255 }
0 commit comments