-
-
Notifications
You must be signed in to change notification settings - Fork 8.5k
stm32/uart: Enable UART clock in low power modes. #17888
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
Conversation
|
Code size report: |
Prevents UART clock from stopping in low power modes (such as WFI). Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
90a9263 to
afd227f
Compare
|
I'm not sure why this is needed? In // Enable some APB peripherals during sleep.
LL_APB1_GRP1_EnableClockLowPower(0xffffffff); // I2C, I3C, LPTIM, SPI, TIM, UART, WWDG
LL_APB2_GRP1_EnableClockLowPower(0xffffffff); // SAI, SPI, TIM, UART
LL_APB4_GRP1_EnableClockLowPower(0xffffffff); // I2C, LPTIM, LPUART, RTC, SPI(Note that the change here does impact pretty much all MCUs, because they define these macros.) |
We don’t use the same
I understand. There are things we could possibly do to mitigate this, for example we could refactor the UART clock enable/disable function, and define a macro for CLK_SLEEP_ENABLE/DISABLE that's only actually defined for N6. This requires even more changes though. |
Do you need to do On the one hand we want them to stay enabled during SLEEP (eg at the idle REPL). On the other hand, if you then want them to shut down during STOP/STANDBY then you can just deinit them and that will fully turn them off. I'm a bit confused as to what the goal here is, what exactly is the issue with just enabling the sleep clocks unconditionally like is already done in |
|
Yes, you're probably right. I will just add this to our init code. |
|
Just to add: all existing MCUs work fine in STOP/STANDBY with all peripherals having their sleep clock enabled (which is the default on them). So it should be the same for the N6, it should be OK to have the peripheral sleep clocks always enabled. |
@dpgeorge Note that some of those bits are reserved. The HAL provides macros with all bits for each bus/group, ex: |
OK, thanks. See #18087. |
Summary
Prevents UART clock from stopping in low power modes (such as WFI). This is needed particularly on the N6, without it Bluetooth fails with:
Testing
Only tested on N6, I don't think it has much effect on other MCUs as they don't seem to gate the clocks during WFI like the N6 does.
Trade-offs and Alternatives
Could only enable it for N6.