Skip to content

Commit 98da3cf

Browse files
tobbaddpgeorge
authored andcommitted
stmhal: Fix clock initialisation of L4 MCUs.
There are 2 changes: - remove early initialisation of LSE and replaced it by LSEDRIVE config (there is no reason to call HAL_RCC_OscConfig twice). - add initialisation of the variables PLLSAI1Source and PLLSAI1M as they are needed in Cube HAL 1.8.1.
1 parent 689dae1 commit 98da3cf

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

stmhal/system_stm32.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -331,12 +331,8 @@ void SystemClock_Config(void)
331331
regarding system frequency refer to product datasheet. */
332332
__HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);
333333
#elif defined(MCU_SERIES_L4)
334-
/* Enable the LSE Oscillator */
335-
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_LSE;
336-
RCC_OscInitStruct.LSEState = RCC_LSE_ON;
337-
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) {
338-
__fatal_error("HAL_RCC_OscConfig");
339-
}
334+
// Configure LSE Drive Capability
335+
__HAL_RCC_LSEDRIVE_CONFIG(RCC_LSEDRIVE_LOW);
340336
#endif
341337

342338
/* Enable HSE Oscillator and activate PLL with HSE as source */
@@ -464,6 +460,8 @@ void SystemClock_Config(void)
464460
PeriphClkInitStruct.UsbClockSelection = RCC_USBCLKSOURCE_PLLSAI1;
465461
PeriphClkInitStruct.RTCClockSelection = RCC_RTCCLKSOURCE_LSE;
466462
PeriphClkInitStruct.RngClockSelection = RCC_RNGCLKSOURCE_PLLSAI1;
463+
PeriphClkInitStruct.PLLSAI1.PLLSAI1Source = RCC_PLLSOURCE_MSI;
464+
PeriphClkInitStruct.PLLSAI1.PLLSAI1M = 1;
467465
PeriphClkInitStruct.PLLSAI1.PLLSAI1N = 24;
468466
PeriphClkInitStruct.PLLSAI1.PLLSAI1P = RCC_PLLP_DIV7;
469467
PeriphClkInitStruct.PLLSAI1.PLLSAI1Q = RCC_PLLQ_DIV2;

0 commit comments

Comments
 (0)