@@ -190,10 +190,10 @@ uint8_t SetSysClock_PLL_HSE(uint8_t bypass)
190
190
191
191
// Select PLL clock as system clock source and configure the HCLK, PCLK1 and PCLK2 clocks dividers
192
192
RCC_ClkInitStruct .ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2 );
193
- RCC_ClkInitStruct .SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK ; // 80 MHz or 48 MHz
194
- RCC_ClkInitStruct .AHBCLKDivider = RCC_SYSCLK_DIV1 ; // 80 MHz or 48 MHz
195
- RCC_ClkInitStruct .APB1CLKDivider = RCC_HCLK_DIV1 ; // 80 MHz or 48 MHz
196
- RCC_ClkInitStruct .APB2CLKDivider = RCC_HCLK_DIV1 ; // 80 MHz or 48 MHz
193
+ RCC_ClkInitStruct .SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK ; // 80 MHz
194
+ RCC_ClkInitStruct .AHBCLKDivider = RCC_SYSCLK_DIV1 ; // 80 MHz
195
+ RCC_ClkInitStruct .APB1CLKDivider = RCC_HCLK_DIV1 ; /* 80 MHz */
196
+ RCC_ClkInitStruct .APB2CLKDivider = RCC_HCLK_DIV1 ; // 80 MHz
197
197
if (HAL_RCC_ClockConfig (& RCC_ClkInitStruct , FLASH_LATENCY_4 ) != HAL_OK ) {
198
198
return 0 ; // FAIL
199
199
}
@@ -217,6 +217,13 @@ uint8_t SetSysClock_PLL_HSE(uint8_t bypass)
217
217
RCC_OscInitStruct .PLL .PLLState = RCC_PLL_NONE ; // No PLL update
218
218
HAL_RCC_OscConfig (& RCC_OscInitStruct );
219
219
220
+ /* Select HSI as clock source for LPUART1 */
221
+ RCC_PeriphClkInit .PeriphClockSelection = RCC_PERIPHCLK_LPUART1 ;
222
+ RCC_PeriphClkInit .Lpuart1ClockSelection = RCC_LPUART1CLKSOURCE_HSI ;
223
+ if (HAL_RCCEx_PeriphCLKConfig (& RCC_PeriphClkInit ) != HAL_OK ) {
224
+ return 0 ; // FAIL
225
+ }
226
+
220
227
// Output clock on MCO1 pin(PA8) for debugging purpose
221
228
#if DEBUG_MCO == 2
222
229
if (bypass == 0 )
@@ -289,6 +296,13 @@ uint8_t SetSysClock_PLL_HSI(void)
289
296
RCC_OscInitStruct .PLL .PLLState = RCC_PLL_NONE ; // No PLL update
290
297
HAL_RCC_OscConfig (& RCC_OscInitStruct );
291
298
299
+ /* Select HSI as clock source for LPUART1 */
300
+ RCC_PeriphClkInit .PeriphClockSelection = RCC_PERIPHCLK_LPUART1 ;
301
+ RCC_PeriphClkInit .Lpuart1ClockSelection = RCC_LPUART1CLKSOURCE_HSI ;
302
+ if (HAL_RCCEx_PeriphCLKConfig (& RCC_PeriphClkInit ) != HAL_OK ) {
303
+ return 0 ; // FAIL
304
+ }
305
+
292
306
// Output clock on MCO1 pin(PA8) for debugging purpose
293
307
#if DEBUG_MCO == 3
294
308
HAL_RCC_MCOConfig (RCC_MCO1 , RCC_MCO1SOURCE_HSI , RCC_MCODIV_1 ); // 16 MHz
@@ -322,7 +336,6 @@ uint8_t SetSysClock_PLL_MSI(void)
322
336
RCC_OscInitStruct .MSIState = RCC_MSI_ON ;
323
337
RCC_OscInitStruct .HSEState = RCC_HSE_OFF ;
324
338
RCC_OscInitStruct .HSIState = RCC_HSI_OFF ;
325
-
326
339
RCC_OscInitStruct .MSICalibrationValue = RCC_MSICALIBRATION_DEFAULT ;
327
340
RCC_OscInitStruct .MSIClockRange = RCC_MSIRANGE_11 ; /* 48 MHz */
328
341
RCC_OscInitStruct .PLL .PLLState = RCC_PLL_ON ;
@@ -342,11 +355,6 @@ uint8_t SetSysClock_PLL_MSI(void)
342
355
PeriphClkInitStruct .UsbClockSelection = RCC_USBCLKSOURCE_MSI ; /* 48 MHz */
343
356
HAL_RCCEx_PeriphCLKConfig (& PeriphClkInitStruct );
344
357
345
- /* Select LSE as clock source for LPUART1 */
346
- PeriphClkInitStruct .PeriphClockSelection = RCC_PERIPHCLK_LPUART1 ;
347
- PeriphClkInitStruct .Lpuart1ClockSelection = RCC_LPUART1CLKSOURCE_LSE ;
348
- HAL_RCCEx_PeriphCLKConfig (& PeriphClkInitStruct );
349
-
350
358
// Select PLL as system clock source and configure the HCLK, PCLK1 and PCLK2 clocks dividers
351
359
RCC_ClkInitStruct .ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2 );
352
360
RCC_ClkInitStruct .SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK ; /* 80 MHz */
@@ -357,6 +365,13 @@ uint8_t SetSysClock_PLL_MSI(void)
357
365
return 0 ; // FAIL
358
366
}
359
367
368
+ /* Select LSE as clock source for LPUART1 */
369
+ PeriphClkInitStruct .PeriphClockSelection = RCC_PERIPHCLK_LPUART1 ;
370
+ PeriphClkInitStruct .Lpuart1ClockSelection = RCC_LPUART1CLKSOURCE_LSE ;
371
+ if (HAL_RCCEx_PeriphCLKConfig (& PeriphClkInitStruct ) != HAL_OK ) {
372
+ return 0 ; // FAIL
373
+ }
374
+
360
375
// Output clock on MCO1 pin(PA8) for debugging purpose
361
376
#if DEBUG_MCO == 4
362
377
HAL_RCC_MCOConfig (RCC_MCO1 , RCC_MCO1SOURCE_MSI , RCC_MCODIV_2 ); // 2 MHz
0 commit comments