8000 nucleo: fix clock source for RTC (LSI instead of LSE) · nuraci/micropython@645aa42 · GitHub
[go: up one dir, main page]

Skip to content

Commit 645aa42

Browse files
committed
nucleo: fix clock source for RTC (LSI instead of LSE)
Signed-off-by: Nunzio Raciti <nunzio.raciti@gmail.com>
1 parent 4022414 commit 645aa42

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

stmhal/rtc.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,15 +263,24 @@ void HAL_RTC_MspInit(RTC_HandleTypeDef *hrtc) {
263263
// set LSE as RTC clock source
264264
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_LSI | RCC_OSCILLATORTYPE_LSE;
265265
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE;
266+
#if !defined(STM32F401xE)
266267
RCC_OscInitStruct.LSEState = RCC_LSE_ON;
267268
RCC_OscInitStruct.LSIState = RCC_LSI_OFF;
269+
#else
270+
RCC_OscInitStruct.LSEState = RCC_LSE_OFF;
271+
RCC_OscInitStruct.LSIState = RCC_LSI_ON;
272+
#endif
268273
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) {
269274
//Error_Handler();
270275
return;
271276
}
272277

273278
PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_RTC;
279+
#if !defined(STM32F401xE)
274280
PeriphClkInitStruct.RTCClockSelection = RCC_RTCCLKSOURCE_LSE;
281+
#else
282+
PeriphClkInitStruct.RTCClockSelection = RCC_RTCCLKSOURCE_LSI;
283+
#endif
275284
if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK) {
276285
//Error_Handler();
277286
return;

0 commit comments

Comments
 (0)
0