Skip to content

Enable LSE for LPUART only if LSE is ready #2642

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
MaJerle opened this issue Jan 25, 2025 · 2 comments · Fixed by #2651
Closed

Enable LSE for LPUART only if LSE is ready #2642

MaJerle opened this issue Jan 25, 2025 · 2 comments · Fixed by #2651
Labels
enhancement New feature or request
Milestone

Comments

@MaJerle
Copy link

MaJerle commented Jan 25, 2025

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);
}

@fpistm
Copy link
Member

fpistm commented Jan 27, 2025

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?

@fpistm fpistm added the enhancement New feature or request label Jan 27, 2025
@MaJerle
Copy link
Author

MaJerle commented Jan 27, 2025

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.

fpistm added a commit to fpistm/Arduino_Core_STM32 that referenced this issue Feb 3, 2025
@fpistm fpistm added this to the 2.10.0 milestone Feb 3, 2025
fpistm added a commit to fpistm/Arduino_Core_STM32 that referenced this issue Feb 4, 2025
@fpistm fpistm closed this as completed in eb243d5 Feb 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Development

Successfully merging a pull request may close this issue.

2 participants