Skip to content

Commit 3fd0714

Browse files
committed
FIX: LPUART clock source selection should be left to serial driver
The clock source selection of LPUART depends on System clocks but also on the serial baudrate. There is a specific computation done in serial driver targets/target_STM/serial_api.c At first start-up the LPUART1 clock selected in SetSysClock was anyway overridden by the serial driver, so this was of no effect. But in case of deep sleep SetSysClock is called again, while the driver isn't, so SetSyClock was corrupting the serial clock configuration. So let's remove these few lines of code which are causing trouble.
1 parent b1b0673 commit 3fd0714

File tree

1 file changed

+0
-21
lines changed
  • targets/TARGET_STM/TARGET_STM32L4/TARGET_STM32L4R5xI/TARGET_NUCLEO_L4R5ZI

1 file changed

+0
-21
lines changed

targets/TARGET_STM/TARGET_STM32L4/TARGET_STM32L4R5xI/TARGET_NUCLEO_L4R5ZI/system_clock.c

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -177,13 +177,6 @@ uint8_t SetSysClock_PLL_HSE(uint8_t bypass)
177177
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE; // No PLL update
178178
HAL_RCC_OscConfig(&RCC_OscInitStruct);
179179

180-
/* Select HSI as clock source for LPUART1 */
181-
RCC_PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_LPUART1;
182-
RCC_PeriphClkInit.Lpuart1ClockSelection = RCC_LPUART1CLKSOURCE_HSI;
183-
if (HAL_RCCEx_PeriphCLKConfig(&RCC_PeriphClkInit) != HAL_OK) {
184-
return 0; // FAIL
185-
}
186-
187180
// Output clock on MCO1 pin(PA8) for debugging purpose
188181
#if DEBUG_MCO == 2
189182
if (bypass == 0) {
@@ -259,13 +252,6 @@ uint8_t SetSysClock_PLL_HSI(void)
259252
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE; // No PLL update
260253
HAL_RCC_OscConfig(&RCC_OscInitStruct);
261254

262-
/* Select HSI as clock source for LPUART1 */
263-
RCC_PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_LPUART1;
264-
RCC_PeriphClkInit.Lpuart1ClockSelection = RCC_LPUART1CLKSOURCE_HSI;
265-
if (HAL_RCCEx_PeriphCLKConfig(&RCC_PeriphClkInit) != HAL_OK) {
266-
return 0; // FAIL
267-
}
268-
269255
// Output clock on MCO1 pin(PA8) for debugging purpose
270256
#if DEBUG_MCO == 3
271257
HAL_RCC_MCOConfig(RCC_MCO1, RCC_MCO1SOURCE_HSI, RCC_MCODIV_1); // 16 MHz
@@ -331,13 +317,6 @@ uint8_t SetSysClock_PLL_MSI(void)
331317
return 0; // FAIL
332318
}
333319

334-
/* Select LSE as clock source for LPUART1 */
335-
PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_LPUART1;
336-
PeriphClkInitStruct.Lpuart1ClockSelection = RCC_LPUART1CLKSOURCE_LSE;
337-
if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK) {
338-
return 0; // FAIL
339-
}
340-
341320
// Output clock on MCO1 pin(PA8) for debugging purpose
342321
#if DEBUG_MCO == 4
343322
HAL_RCC_MCOConfig(RCC_MCO1, RCC_MCO1SOURCE_MSI, RCC_MCODIV_2); // 2 MHz

0 commit comments

Comments
 (0)