@@ -205,18 +205,22 @@ WEAK void SystemClock_Config(void)
205
205
206
206
while (!__HAL_PWR_GET_FLAG (PWR_FLAG_VOSRDY)) {}
207
207
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
+
208
214
/* * Initializes the RCC Oscillators according to the specified parameters
209
215
* in the RCC_OscInitTypeDef structure.
210
216
*/
211
217
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_CSI | RCC_OSCILLATORTYPE_HSI48
212
- | RCC_OSCILLATORTYPE_HSE | RCC_OSCILLATORTYPE_HSI ;
218
+ | RCC_OSCILLATORTYPE_HSE | RCC_OSCILLATORTYPE_LSE ;
213
219
RCC_OscInitStruct.CSIState = RCC_CSI_ON;
214
220
RCC_OscInitStruct.CSICalibrationValue = RCC_CSICALIBRATION_DEFAULT;
215
221
RCC_OscInitStruct.HSI48State = RCC_HSI48_ON;
216
222
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;
220
224
RCC_OscInitStruct.PLL .PLLState = RCC_PLL_ON;
221
225
RCC_OscInitStruct.PLL .PLLSource = RCC_PLL1_SOURCE_HSE;
222
226
RCC_OscInitStruct.PLL .PLLM = 5 ;
@@ -233,7 +237,7 @@ WEAK void SystemClock_Config(void)
233
237
234
238
/* * Initializes the CPU, AHB and APB buses clocks
235
239
*/
236
- RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_SYSCLK
240
+ RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK
237
241
| RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2
238
242
| RCC_CLOCKTYPE_PCLK3;
239
243
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
@@ -257,28 +261,28 @@ WEAK void SystemClock_Config(void)
257
261
| RCC_PERIPHCLK_SPI1 | RCC_PERIPHCLK_SPI2
258
262
| RCC_PERIPHCLK_SPI3 | RCC_PERIPHCLK_SPI4
259
263
| 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 ;
266
270
PeriphClkInitStruct.PLL2 .PLL2RGE = RCC_PLL2_VCIRANGE_2;
267
271
PeriphClkInitStruct.PLL2 .PLL2VCOSEL = RCC_PLL2_VCORANGE_WIDE;
268
272
PeriphClkInitStruct.PLL2 .PLL2FRACN = 0 ;
269
273
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 ;
273
277
PeriphClkInitStruct.PLL3 .PLL3P = 2 ;
274
278
PeriphClkInitStruct.PLL3 .PLL3Q = 5 ;
275
279
PeriphClkInitStruct.PLL3 .PLL3R = 2 ;
276
- PeriphClkInitStruct.PLL3 .PLL3RGE = RCC_PLL3_VCIRANGE_3 ;
280
+ PeriphClkInitStruct.PLL3 .PLL3RGE = RCC_PLL3_VCIRANGE_2 ;
277
281
PeriphClkInitStruct.PLL3 .PLL3VCOSEL = RCC_PLL3_VCORANGE_WIDE;
278
282
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 ;
282
286
PeriphClkInitStruct.Sdmmc1ClockSelection = RCC_SDMMC1CLKSOURCE_PLL1Q;
283
287
PeriphClkInitStruct.AdcDacClockSelection = RCC_ADCDACCLKSOURCE_PLL2R;
284
288
PeriphClkInitStruct.Lpuart1ClockSelection = RCC_LPUART1CLKSOURCE_PLL2Q;
0 commit comments