-
Notifications
You must be signed in to change notification settings - Fork 3k
STM32: Add HSE support to RTC #14243
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
2c1f04d
to
4a5d603
Compare
@boraozgen, thank you for your changes. |
4a5d603
to
7db9f17
Compare
Hi Need also to test, but as a first comment, I think that HSE is stopped during deepsleep (and not LSE) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Compilation failed for STM32L4
Tests failed for STM32F429 for ex:
| NUCLEO_F429ZI-ARMC6 | NUCLEO_F429ZI | drivers-tests-tests-mbed_drivers-rtc | FAIL | 17.02 | default |
| NUCLEO_F429ZI-ARMC6 | NUCLEO_F429ZI | hal-tests-tests-mbed_hal-rtc | TIMEOUT | 72.04 | default |
| NUCLEO_F429ZI-ARMC6 | NUCLEO_F429ZI | hal-tests-tests-mbed_hal-rtc_reset | FAIL | 17.08 | default |
I believe this should be left to the application developer. One can lock the deep sleep in the main function. |
Not so sure... Or you should add explicit warnings in some comments somewhere... |
Should we add the switch into targets.json, where we can provide a comment as well? I'm not sure which is the correct place as I am not very familiar with the document. For example here: Line 1137 in c153880
|
NO... targets.json is defining the default configuration. And default and working configuration is RTC with LSE. You can change this default configuration in your local mbed_app.json file. Note that I still couldn't make tests working with this configuration... |
I did not mean to set the switch, but to define it, similar to how What is blocking the tests? It should give an preprocessor error in case it is enabled with an invalid target (any target except F2/F3/F4). |
Nice way could be to add a config for RTC clock, with default value LSE, and sometimes LSI when there is no LSE. |
See above: |
I just ran the tests on my side. The first one seems to pass for me. Is there something else in your configuration?
The others fail, and the reasons are clear. I don't exactly understand why
This is a good idea, I will suggest an implementation when the tests issue is cleared. |
Maybe you should have a look on RTC init after reset: |
Good clue, I managed to pass the reset test when I added the same peripheral clock initialization with I will soon update the PR with the suggested changes in the configuration. |
I wanted to add the setting to the configuration and thought of keeping the same structure as the LPUART clock source as in here: Lines 1142 to 1145 in 2660621
I then realized that there is a collision between that and the lse_available setting. For example in serial_api.c there are no checks if lse_available is set or not. Should I do the same, ignoring the lse_available setting and letting the user to make sure LSE is available before setting the RTC clock to LSE?
|
This pull request has automatically been marked as stale because it has had no recent activity. @boraozgen, please carry out any necessary work to get the changes merged. Thank you for your contributions. |
@jeromecoutant could you please comment on my last question? |
@jeromecoutant this is awaiting your feedback... |
This PR cannot be merged due to conflicts. Please rebase to resolve them. |
c3d145f
to
257e466
Compare
Finally I have come up with a solution, which in my opinion is too much preprocessor magic, but this is how Mbed works :) I first considered the masking logic similar to the I finally decided on choosing between the options Each option passes the following tests with GCC and F429ZI. For HSE to pass, LPTICKER must be disabled using
|
Jenkins CI Test : ✔️ SUCCESSBuild Number: 1 | 🔒 Jenkins CI Job | 🌐 Logs & ArtifactsCLICK for Detailed Summary
|
@jeromecoutant Can this be merged now? |
@0xc0170 not tested yet, |
@jeromecoutant As I understood we can merge this, tests can be run on your side and if anything found we can fix or revert this? Let me know |
@0xc0170 can we use this PR for the review changes or do I have to open a new one? |
Summary of changes
Hey folks, especially @jeromecoutant,
We have a requirement to supply the RTC from HSE. This is currently not possible in Mbed. I tinkered a little bit with the RTC port to enable this.
I used the reference manuals of STM32F411/412 and tested on the respective MCUs. I am not sure if this applies to all of the STM32 family, would be great if someone checks this.
According to the STM32F411 reference manual, the requirements are:
My implementation:
RTC_FROM_HSE
is defined as a macro, could be set inmbed_app.json
or in the target definition.PeriphClkInitStruct.RTCClockSelection
prescaler calculated automatically fromHSE_VALUE
.RTC_CLOCK
is set to1000000U
(per requirement)PREDIV_A_VALUE
is set to124
forPREDIV_A_VALUE + 1
to be a divisor of 1 MHz.I am not sure if
lp_ticker
is affected by this, or any changes are needed there...Impact of changes
Migration actions required
Documentation
Needs to be amended.
Pull request type
Test results
Reviewers
@jeromecoutant