-
Notifications
You must be signed in to change notification settings - Fork 976
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
Restore RTC Clock after power off #266
Comments
Shouldn't setRTC be a subroutine that can be called on it's on? AFAIK RTC's have an internal battery that keep time. Maybe this would help? |
You talk about after a call of low power shutdown()? |
At the moment I have only implemented the RTC and when I remove the power supply and then poweron the discovery board again, the clock starts from the time that I initially set. I suppose this happens because it's like pressing the RESET button, and then I'm going to reinitialize the RTC. To keep the time even after restoring the power, how should I do? |
Which board? I assume you have a battery connected to VBAT. |
I'm trying with a STM32VLDISCOVERY, so STM32F100RBT6. |
It required to save the date/time in backup registers using HAL_RTCEx_BKUPWrite/HAL_RTCEx_BKUPRead. |
Yes it will be an enhancement. |
Indicatively, what times for processing and release do you suppose? |
I don't know exactly. Several stuff in //. I will do my best. |
Thank you very very much! |
Hi @fpistm I think the issue is in the core RTC driver implementation. The RTC_Init() function unconditionally initializes the RTC calendar with an arbitrary date/time. I have a project where we use a separate VBAT and I had to remove the calendar initialization in order to keep the correct date/time. I'm referring to line Arduino_Core_STM32/cores/arduino/stm32/rtc.c Line 321 in e872a35
/*Sunday 1st January 2017*/
RTC_SetDate(17, 1, 1, 7);
/*at 0:0:0*/
RTC_SetTime(0,0,0,0,AM); In my project I made a simple library to handle backup registers and I set a flag to remember if the calendar has been initialized already. If not, my code uses the STM32RTC library to set the initial date/time (or it could get them from other sources, e.g. NTP or GPS) . I think calendar initialization should be left to the application and not done in the core. This eliminates the problem of date/time being overwritten when you exit backup (VBAT) mode. At least that's what I've done in my fork of the core, I just removed those 2 initial calls to If you are interested, initial code for a library to handle backup registers can be found at: https://github.com/RoboTech-srl/STM32BackupRegs |
This is not an issue ;) |
Ah ah... well, it was an issue for me, because I wanted to use backup mode. :-) The logic behind I'm not sure how you planned to handle this, but I was thinking that removing those two calls from the core could do no harm anyway. Are those calls to |
Currently, I don't know exactly. |
Hi @fpistm, |
At least date and time but this is opened. This can be take in account to be more generic. Any help/tips are welcome |
Fix stm32duino#266 Signed-off-by: Frederic.Pillon <frederic.pillon@st.com>
Fix stm32duino#266 Signed-off-by: Frederic.Pillon <frederic.pillon@st.com>
Fix stm32duino#266 Signed-off-by: Frederic.Pillon <frederic.pillon@st.com>
Hi @fpistm, |
In fact Date is not saved on F1. |
Fix stm32duino#266 Signed-off-by: Frederic.Pillon <frederic.pillon@st.com>
How would it be possible to keep the time even after the power supply was restored?
Now, when power is restored, the microcontroller restarts from the setup() routine (where there is rtc.setTime), it takes the new time and loses the current time.
Is it possible to implement the programmable voltage detector (PVD) to send the microcontroller in low power mode, and wake up when power is restored without going through setup()?
Thank you in advance
The text was updated successfully, but these errors were encountered: