What causes the stm32 RTC to reset?

Post here all questions related to STM32 core if you can't find a relevant section!
Bambo
Posts: 75
Joined: Wed Jan 15, 2020 8:36 pm

Re: What causes the stm32 RTC to reset?

Post by Bambo »

User avatar
fpiSTM
Posts: 1738
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 91
Location: Le Mans
Contact:

Re: What causes the stm32 RTC to reset?

Post by fpiSTM »

Bambo wrote: Wed May 20, 2020 11:21 am Bug report created here: https://github.com/stm32duino/STM32LowPower/issues/22
This is not a bug.
Simply wrong usage of the API. See my comment here:
https://github.com/stm32duino/STM32LowP ... -631491658
GonzoG
Posts: 403
Joined: Wed Jan 15, 2020 11:30 am
Answers: 27
Location: Prudnik, Poland

Re: What causes the stm32 RTC to reset?

Post 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
User avatar
blue-man
Posts: 51
Joined: Mon Mar 23, 2020 5:02 pm

Re: What causes the stm32 RTC to reset?

Post by blue-man »

fpiSTM wrote: Wed May 20, 2020 2:02 pm This is not a bug.
Simply wrong usage of the API. See my comment here:
https://github.com/stm32duino/STM32LowP ... -631491658
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?
User avatar
fpiSTM
Posts: 1738
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 91
Location: Le Mans
Contact:

Re: What causes the stm32 RTC to reset?

Post by fpiSTM »

STM32F1 has no date retention a PR has been submitted for this but I have to find time to review it...
User avatar
blue-man
Posts: 51
Joined: Mon Mar 23, 2020 5:02 pm

Re: What causes the stm32 RTC to reset?

Post 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?
User avatar
blue-man
Posts: 51
Joined: Mon Mar 23, 2020 5:02 pm

Re: What causes the stm32 RTC to reset?

Post 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 ...
Last edited by blue-man on Wed Sep 29, 2021 2:58 pm, edited 1 time in total.
User avatar
fpiSTM
Posts: 1738
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 91
Location: Le Mans
Contact:

Re: What causes the stm32 RTC to reset?

Post by fpiSTM »

blue-man wrote: Wed Sep 29, 2021 2:21 pm
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?
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.
User avatar
blue-man
Posts: 51
Joined: Mon Mar 23, 2020 5:02 pm

Re: What causes the stm32 RTC to reset?

Post 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.
Post Reply

Return to “General discussion”