-
Notifications
You must be signed in to change notification settings - Fork 2.1k
cpu/stm32: reworked RTC implementation #7504
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
63e9c80
to
d5e02ac
Compare
@haukepetersen, tested on nucleo-l053 and nucleo144-f207: works. |
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.
Just a minor comment
cpu/stm32_common/periph/rtc.c
Outdated
(((uint32_t)byte2bcd(time->tm_mon + 1) << 8) & (RTC_DR_MT | RTC_DR_MU)) | | ||
(((uint32_t)byte2bcd(time->tm_mday) << 0) & (RTC_DR_DT | RTC_DR_DU))); | ||
/* set clock to 24-h mode and enable timestamps */ | ||
RTC->CR = RTC_CR_TSE; |
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.
This should be done after prescaler setting
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.
fixed
It would be great if you could disable RTC output in init with this: /* Disable alternate function outputs */
RTC->TAFCR = RTC_TAFCR_TSINSEL | RTC_TAFCR_TAMPINSEL; that way we could close #7326 in favor of that one. |
Thanks for the tests and reviews. I optimized the driver again:
@vincent-d: I think the driver should not use any pins as it is configured now (alarm and tamper are both not enabled). So the |
@haukepetersen I need to check again, maybe this was because alarm was active, but I was not able to use PC13 as gpio, that's why I added that line. |
Which board did you encounter this on? Might be good if we find the exact cause for this... |
On our own hardware. I'm retesting, and I'll try to reproduce on a nucleo. |
I just found some more specific doc for the f411 (ref manual, section 8.3.15 |
Just checked, on the |
I ran some tests (on nucleo144-f207), it's becoming a bit more clear. Status is:
But if you do: /* reset configuration */
RTC->CR = 0;
RTC->ISR = 0; right after |
Ok, how about the change in the latest commit then? We just can't set |
Indeed! Retested your latest commit, works fine. |
ACK |
f0cb9d5
to
3897d00
Compare
squashed. |
ACKed and all green -> go. Thanks again for the help here! |
Nice one! |
Successor of #6504 and should solve #6502 in the same way.
This PR reworks the RTC driver for the STM32 family. It works now with all but the
stm32f1
(which it never did, although the feature was enabled for the iotlab...). Also this rework fixes some bugs in the old driver, e.g.rtc_set
did not always work as expected.The test application got also some improvements.
What I did not check is, weather all nucleo boards have a low frequency oscillator on board, so that we can safely enable the
LSE
clock for all nucleo boards. But this is something we can always do later.This PR should be tested for at least one member of each STM family. Tested so far for the
nucleo-f072
stm32f3discovery
nucleo-f411
nucleo-l152
nucleo-l476
nucleo144-f746
nucleo-l053
nucleo144-f207
Could someone verify the changes for a
stm32f2
and astm32l0
? Thx.