@@ -205,18 +205,22 @@ WEAK void SystemClock_Config(void)
205205
206206 while (!__HAL_PWR_GET_FLAG (PWR_FLAG_VOSRDY)) {}
207207
208+ /* * Configure LSE Drive Capability
209+ * Warning : Only applied when the LSE is disabled.
210+ */
211+ HAL_PWR_EnableBkUpAccess ();
212+ __HAL_RCC_LSEDRIVE_CONFIG (RCC_LSEDRIVE_LOW);
213+
208214 /* * Initializes the RCC Oscillators according to the specified parameters
209215 * in the RCC_OscInitTypeDef structure.
210216 */
211217 RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_CSI | RCC_OSCILLATORTYPE_HSI48
212- | RCC_OSCILLATORTYPE_HSE | RCC_OSCILLATORTYPE_HSI ;
218+ | RCC_OSCILLATORTYPE_HSE | RCC_OSCILLATORTYPE_LSE ;
213219 RCC_OscInitStruct.CSIState = RCC_CSI_ON;
214220 RCC_OscInitStruct.CSICalibrationValue = RCC_CSICALIBRATION_DEFAULT;
215221 RCC_OscInitStruct.HSI48State = RCC_HSI48_ON;
216222 RCC_OscInitStruct.HSEState = RCC_HSE_BYPASS_DIGITAL;
217- RCC_OscInitStruct.HSIState = RCC_HSI_ON;
218- RCC_OscInitStruct.HSIDiv = RCC_HSI_DIV1;
219- RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT;
223+ RCC_OscInitStruct.LSEState = RCC_LSE_ON;
220224 RCC_OscInitStruct.PLL .PLLState = RCC_PLL_ON;
221225 RCC_OscInitStruct.PLL .PLLSource = RCC_PLL1_SOURCE_HSE;
222226 RCC_OscInitStruct.PLL .PLLM = 5 ;
@@ -233,7 +237,7 @@ WEAK void SystemClock_Config(void)
233237
234238 /* * Initializes the CPU, AHB and APB buses clocks
235239 */
236- RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_SYSCLK
240+ RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK
237241 | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2
238242 | RCC_CLOCKTYPE_PCLK3;
239243 RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
@@ -257,28 +261,28 @@ WEAK void SystemClock_Config(void)
257261 | RCC_PERIPHCLK_SPI1 | RCC_PERIPHCLK_SPI2
258262 | RCC_PERIPHCLK_SPI3 | RCC_PERIPHCLK_SPI4
259263 | RCC_PERIPHCLK_SPI5 | RCC_PERIPHCLK_SPI6;
260- PeriphClkInitStruct.PLL2 .PLL2Source = RCC_PLL2_SOURCE_CSI ;
261- PeriphClkInitStruct.PLL2 .PLL2M = 1 ;
262- PeriphClkInitStruct.PLL2 .PLL2N = 32 ;
263- PeriphClkInitStruct.PLL2 .PLL2P = 1 ;
264- PeriphClkInitStruct.PLL2 .PLL2Q = 4 ;
265- PeriphClkInitStruct.PLL2 .PLL2R = 2 ;
264+ PeriphClkInitStruct.PLL2 .PLL2Source = RCC_PLL2_SOURCE_HSE ;
265+ PeriphClkInitStruct.PLL2 .PLL2M = 5 ;
266+ PeriphClkInitStruct.PLL2 .PLL2N = 100 ;
267+ PeriphClkInitStruct.PLL2 .PLL2P = 2 ;
268+ PeriphClkInitStruct.PLL2 .PLL2Q = 15 ;
269+ PeriphClkInitStruct.PLL2 .PLL2R = 4 ;
266270 PeriphClkInitStruct.PLL2 .PLL2RGE = RCC_PLL2_VCIRANGE_2;
267271 PeriphClkInitStruct.PLL2 .PLL2VCOSEL = RCC_PLL2_VCORANGE_WIDE;
268272 PeriphClkInitStruct.PLL2 .PLL2FRACN = 0 ;
269273 PeriphClkInitStruct.PLL2 .PLL2ClockOut = RCC_PLL2_DIVQ | RCC_PLL2_DIVR;
270- PeriphClkInitStruct.PLL3 .PLL3Source = RCC_PLL3_SOURCE_CSI ;
271- PeriphClkInitStruct.PLL3 .PLL3M = 2 ;
272- PeriphClkInitStruct.PLL3 .PLL3N = 125 ;
274+ PeriphClkInitStruct.PLL3 .PLL3Source = RCC_PLL3_SOURCE_HSE ;
275+ PeriphClkInitStruct.PLL3 .PLL3M = 5 ;
276+ PeriphClkInitStruct.PLL3 .PLL3N = 50 ;
273277 PeriphClkInitStruct.PLL3 .PLL3P = 2 ;
274278 PeriphClkInitStruct.PLL3 .PLL3Q = 5 ;
275279 PeriphClkInitStruct.PLL3 .PLL3R = 2 ;
276- PeriphClkInitStruct.PLL3 .PLL3RGE = RCC_PLL3_VCIRANGE_3 ;
280+ PeriphClkInitStruct.PLL3 .PLL3RGE = RCC_PLL3_VCIRANGE_2 ;
277281 PeriphClkInitStruct.PLL3 .PLL3VCOSEL = RCC_PLL3_VCORANGE_WIDE;
278282 PeriphClkInitStruct.PLL3 .PLL3FRACN = 0 ;
279- PeriphClkInitStruct.PLL3 .PLL3ClockOut = RCC_PLL3_DIVQ;
280- PeriphClkInitStruct.Sai1ClockSelection = RCC_SAI1CLKSOURCE_PLL2P ;
281- PeriphClkInitStruct.Sai2ClockSelection = RCC_SAI2CLKSOURCE_PLL2P ;
283+ PeriphClkInitStruct.PLL3 .PLL3ClockOut = RCC_PLL3_DIVP | RCC_PLL3_DIVQ;
284+ PeriphClkInitStruct.Sai1ClockSelection = RCC_SAI1CLKSOURCE_PLL3P ;
285+ PeriphClkInitStruct.Sai2ClockSelection = RCC_SAI2CLKSOURCE_PLL3P ;
282286 PeriphClkInitStruct.Sdmmc1ClockSelection = RCC_SDMMC1CLKSOURCE_PLL1Q;
283287 PeriphClkInitStruct.AdcDacClockSelection = RCC_ADCDACCLKSOURCE_PLL2R;
284288 PeriphClkInitStruct.Lpuart1ClockSelection = RCC_LPUART1CLKSOURCE_PLL2Q;
0 commit comments