Page 2 of 2
Re: What causes the stm32 RTC to reset?
Posted: Wed May 20, 2020 11:21 am
by Bambo
Re: What causes the stm32 RTC to reset?
Posted: Wed May 20, 2020 2:02 pm
by fpiSTM
This is not a bug.
Simply wrong usage of the API. See my comment here:
https://github.com/stm32duino/STM32LowP ... -631491658
Re: What causes the stm32 RTC to reset?
Posted: Tue May 26, 2020 2:52 pm
by GonzoG
Bambo wrote: ↑Wed May 20, 2020 10:47 am
Ok so i've added the setClockSource() to the RTC code but now it doesn't restart at all once shutdown is called?
"rtc.setClockSource(STM32RTC::LSE_CLOCK); " needs to be called before rtc.begin();
all about rtc library:
https://github.com/stm32duino/STM32RTC
Re: What causes the stm32 RTC to reset?
Posted: Wed Sep 29, 2021 1:27 pm
by blue-man
I am entering the same problem more complicated.
The
time is saved during reset and complete power off with a CR2032 battery,
but not the date and weekday.
rtc.isTimeSet() reads correct as one, but the date is lost after the next reset or power lost.
I have tested this with two different Blue-Pills, one named with CKS32 and another that seems to be a STM32F103C8T6 clone.
This is my initialization:
Code: Select all
#include <STM32RTC.h>
/* Get the rtc object */
STM32RTC& rtc = STM32RTC::getInstance();
void setup() {
Serial.begin(115200);
print_version();
rtc.setClockSource(STM32RTC::LSE_CLOCK);
rtc.begin(); // initialize RTC 24H format
}
I compiled it with the same result for
* Generic STM32F1 series
** Bluepill F103C6 (32K)
and alternative
** Bluepill F103CB (or C8 with 128k)
STM32duino RTC is Version 1.1.0
HAL-Core V 1.9.0
Is this caused by the cloned MCU's or another problem?
Re: What causes the stm32 RTC to reset?
Posted: Wed Sep 29, 2021 1:33 pm
by fpiSTM
STM32F1 has no date retention a PR has been submitted for this but I have to find time to review it...
Re: What causes the stm32 RTC to reset?
Posted: Wed Sep 29, 2021 2:21 pm
by blue-man
fpiSTM wrote: ↑Wed Sep 29, 2021 1:33 pm
STM32F1 has no date retention a PR has been submitted for this but I have to find time to review it...
O.K. Thanks for the quick answer.
I think this will be a hardware problem, because it makes no sense that there is an option to forget the date, when the time is rescued.
That's a pity, because a complete timestamp is needed for logs.
I have upgraded to core 2.0.0 and the problem still exists.
Additional i tested with a different third Blue-Pill.
Here i could find a similar post regarding this issue:
https://community.st.com/s/question/0D5 ... osing-date
This links to
https://community.st.com/s/question/0D5 ... p-register and
https://community.st.com/s/feed/0D50X00009XkW1nSAF
Hopefully this helps?
Re: What causes the stm32 RTC to reset?
Posted: Wed Sep 29, 2021 2:53 pm
by blue-man
The described solution to modify stm32f1xx_hal_rtc.c and rtc.c does not work, because the compilation fails in rtc.c.
It's not so easy to understand what is happening in detail there ...
Re: What causes the stm32 RTC to reset?
Posted: Wed Sep 29, 2021 2:57 pm
by fpiSTM
This is linked to the STM32 feature. The STM32F1 RTC IP does not do date retention. That's all. That's why a software solution is to use the backup register as it was done in the PR opened.
Re: What causes the stm32 RTC to reset?
Posted: Wed Sep 29, 2021 3:01 pm
by blue-man
fpiSTM wrote: ↑Wed Sep 29, 2021 2:57 pm
This is linked to the STM32 feature. The STM32F1 RTC IP does not do date retention. That's all. That's why a software solution is to use the backup register as it was done in the PR opened.
O.K. This is clear now.
Then i will create an workaround.
The last date must be extracted from the logs.