Skip to content

Commit a148ed2

Browse files
committed
stm32/system_stm32: Fix LSE initialization for STM32H7/F4/F7.
The LSE oscillator was never being enabled for STM32H7, F4, and F7 families. The code would set the RTC clock source to LSE via HAL_RCCEx_PeriphCLKConfig() but never called HAL_RCC_OscInit() with RCC_OSCILLATORTYPE_LSE to actually enable the oscillator. This fix adds LSE oscillator initialization following the pattern already used successfully on STM32L4 boards. When MICROPY_HW_RTC_USE_LSE is enabled, the LSE is now properly initialized before being selected as the RTC clock source. Verified on STM32H747I-DISCO: LSEON=1, LSERDY=1, RTCSEL=LSE. Signed-off-by: Andrew Leech <[email protected]>
1 parent 9999553 commit a148ed2

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

ports/stm32/system_stm32.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,11 @@ MP_WEAK void SystemClock_Config(void) {
249249
RCC_OscInitStruct.OscillatorType |= RCC_OSCILLATORTYPE_HSI48;
250250
#endif
251251

252+
#if MICROPY_HW_RTC_USE_LSE
253+
RCC_OscInitStruct.LSEState = RCC_LSE_ON;
254+
RCC_OscInitStruct.OscillatorType |= RCC_OSCILLATORTYPE_LSE;
255+
#endif
256+
252257
RCC_OscInitStruct.PLL.PLLSource = MICROPY_HW_RCC_PLL_SRC;
253258

254259
#elif defined(STM32L4)

0 commit comments

Comments
 (0)