Skip to content

Commit 41ed923

Browse files
committed
LPUART CLOCK SOURCE SELECTION 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. For targets L496 and L5. Taking into account device TRNG in L5 configuration
1 parent 6068428 commit 41ed923

File tree

2 files changed

+3
-28
lines changed

2 files changed

+3
-28
lines changed

targets/TARGET_STM/TARGET_STM32L4/TARGET_STM32L496xG/system_clock.c

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -154,13 +154,6 @@ MBED_WEAK uint8_t SetSysClock_PLL_HSE(uint8_t bypass)
154154
}
155155
#endif /* DEVICE_USBDEVICE */
156156

157-
/* Select HSI as clock source for LPUART1 */
158-
RCC_PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_LPUART1;
159-
RCC_PeriphClkInit.Lpuart1ClockSelection = RCC_LPUART1CLKSOURCE_HSI;
160-
if (HAL_RCCEx_PeriphCLKConfig(&RCC_PeriphClkInit) != HAL_OK) {
161-
return 0; // FAIL
162-
}
163-
164157
// Output clock on MCO1 pin(PA8) for debugging purpose
165158
#if DEBUG_MCO == 2
166159
if (bypass == 0) {
@@ -224,13 +217,6 @@ uint8_t SetSysClock_PLL_HSI(void)
224217
}
225218
#endif /* DEVICE_USBDEVICE */
226219

227-
/* Select HSI as clock source for LPUART1 */
228-
RCC_PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_LPUART1;
229-
RCC_PeriphClkInit.Lpuart1ClockSelection = RCC_LPUART1CLKSOURCE_HSI;
230-
if (HAL_RCCEx_PeriphCLKConfig(&RCC_PeriphClkInit) != HAL_OK) {
231-
return 0; // FAIL
232-
}
233-
234220
// Output clock on MCO1 pin(PA8) for debugging purpose
235221
#if DEBUG_MCO == 3
236222
HAL_RCC_MCOConfig(RCC_MCO1, RCC_MCO1SOURCE_HSI, RCC_MCODIV_1); // 16 MHz
@@ -303,13 +289,6 @@ uint8_t SetSysClock_PLL_MSI(void)
303289
return 0; // FAIL
304290
}
305291

306-
/* Select LSE as clock source for LPUART1 */
307-
PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_LPUART1;
308-
PeriphClkInitStruct.Lpuart1ClockSelection = RCC_LPUART1CLKSOURCE_LSE;
309-
if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK) {
310-
return 0; // FAIL
311-
}
312-
313292
// Output clock on MCO1 pin(PA8) for debugging purpose
314293
#if DEBUG_MCO == 4
315294
HAL_RCC_MCOConfig(RCC_MCO1, RCC_MCO1SOURCE_MSI, RCC_MCODIV_2); // 2 MHz

targets/TARGET_STM/TARGET_STM32L5/system_clock.c

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -177,16 +177,12 @@ uint8_t SetSysClock_PLL_MSI(void)
177177
return 0; // FAIL
178178
}
179179

180-
// Default STDIO is LPUART1
181-
RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0};
182180
#if DEVICE_TRNG
183-
PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_LPUART1 | RCC_PERIPHCLK_RNG;
181+
RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0};
182+
PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_RNG;
184183
PeriphClkInitStruct.RngClockSelection = RCC_RNGCLKSOURCE_HSI48;
185-
#else
186-
PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_LPUART1;
187-
#endif
188-
PeriphClkInitStruct.Lpuart1ClockSelection = RCC_LPUART1CLKSOURCE_LSE;
189184
HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct);
185+
#endif
190186

191187
return 1; // OK
192188
}

0 commit comments

Comments
 (0)