Skip to content

Enable LSE for LPUART only if LSE is ready #2642

@MaJerle

Description

@MaJerle

In the current configuration, LSE is forced selected when baudrate <= 9600 is selected for HW Serial.
If LSE is not present UART kernel won't work.

A propose is to add a check after enabling the LSE, if the LSE is ready. Use the LL_RCC_LSE_IsReady() before changing the kernel clock of the LPUART.

if (baudrate <= 9600) {
/* Enable the clock if not already set by user */
enableClock(LSE_CLOCK);
if (obj->uart == LPUART1) {
__HAL_RCC_LPUART1_CONFIG(RCC_LPUART1CLKSOURCE_LSE);
}
#if defined(LPUART2_BASE)
if (obj->uart == LPUART2) {
__HAL_RCC_LPUART2_CONFIG(RCC_LPUART2CLKSOURCE_LSE);
}
#endif
#if defined(LPUART3_BASE)
if (obj->uart == LPUART3) {
__HAL_RCC_LPUART3_CONFIG(RCC_LPUART3CLKSOURCE_LSE);
}

Activity

fpistm

fpistm commented on Jan 27, 2025

@fpistm
Member

Hi @MaJerle
Nice to see you here 😉
You're right a check can be added.
I guess it could be added here:

if (__HAL_RCC_GET_FLAG(RCC_FLAG_LSERDY) == RESET) {

Please, could you create a PR for this?

MaJerle

MaJerle commented on Jan 27, 2025

@MaJerle
Author

I'm no expert in the STM32duino development processes, as such I prefer to not create PRs that may be wrongly coded.

The check should be added before LPUART kernel clock is being selected, in uart.c file.

added a commit that references this issue on Feb 3, 2025
c157489
added this to the 2.10.0 milestone on Feb 3, 2025
added a commit that references this issue on Feb 4, 2025
da21c30
added a commit that references this issue on Feb 4, 2025
eb243d5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    Status

    Done

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Enable LSE for LPUART only if LSE is ready · Issue #2642 · stm32duino/Arduino_Core_STM32