STM32F1xx RTC date problem

Post here first, or if you can't find a relevant section!
Post Reply
saeed144
Posts: 36
Joined: Mon Sep 21, 2020 10:11 am

STM32F1xx RTC date problem

Post by saeed144 »

Hi everyone
I heard HAL function in STM32F1xx series have a bug in RTC! when micro reset time value is correct but date value reset too and show 0
there are some modification stm32f1xx_hal_rtc to solve this problem, but what about Arduino IDE?
Howto solve this problem in Arduino_IDE?
GonzoG
Posts: 403
Joined: Wed Jan 15, 2020 11:30 am
Answers: 26
Location: Prudnik, Poland

Re: STM32F1xx RTC date problem

Post by GonzoG »

It's not a bug. RTC in F1 doesn't support calendar so date is kept only till it's powered down or reset.
saeed144
Posts: 36
Joined: Mon Sep 21, 2020 10:11 am

Re: STM32F1xx RTC date problem

Post by saeed144 »

You mean there is no solution? :cry:
mrburnette
Posts: 633
Joined: Thu Dec 19, 2019 1:23 am
Answers: 7

Re: STM32F1xx RTC date problem

Post by mrburnette »

saeed144 wrote: Sun Nov 15, 2020 7:57 am Hi everyone
I heard HAL function in STM32F1xx series have a bug in RTC! when micro reset time value is correct but date value reset too and show 0
there are some modification stm32f1xx_hal_rtc to solve this problem, but what about Arduino IDE?
Howto solve this problem in Arduino_IDE?
Is this "hypothetical" or have you experienced the issue?
IMO, hypothetical concerns mean you need to do a test/experiment.

Arduino core by STM rides on top (wrapper) so the underlying core code used by Arduino is HAL/LL/CMSIS
https://github.com/stm32duino/Arduino_Core_STM32
This porting is based on:

STM32Cube MCU Packages including:
- The HAL hardware abstraction layer, enabling portability between different STM32 devices via standardized API calls
- The Low-Layer (LL) APIs, a light-weight, optimized, expert oriented set of APIs designed for both performance and runtime efficiency
- CMSIS device defintion for STM32

CMSIS: Cortex Microcontroller Software Interface Standard (CMSIS) is a vendor-independent hardware abstraction layer for the Cortex®-M processor series and defines generic tool interfaces. It has been packaged as a module for Arduino IDE: https://github.com/stm32duino/ArduinoModule-CMSIS

GNU Arm Embedded Toolchain: Arm Embedded GCC compiler, libraries and other GNU tools necessary for bare-metal software development on devices based on the Arm Cortex-M. Packages are provided thanks The xPack GNU Arm Embedded GCC: https://github.com/xpack-dev-tools/arm- ... -gcc-xpack
ag123
Posts: 1653
Joined: Thu Dec 19, 2019 5:30 am
Answers: 24

Re: STM32F1xx RTC date problem

Post by ag123 »

saeed144 wrote: Sun Nov 15, 2020 3:53 pm You mean there is no solution? :cry:
connect VBAT to a 3v coin cell, keeps time for a long time
mlundin
Posts: 94
Joined: Wed Nov 04, 2020 1:20 pm
Answers: 6
Location: Sweden

Re: STM32F1xx RTC date problem

Post by mlundin »

The STM32F1xx RTC only has one register that normally counts seconds, using the count of seconds modulo 86400 (number of seconds in a day) it can keep track of the time of day, when this count gets larger than 86400 we know that one day has passed. There is no information in the RTC hardware about the what day, date, year and month. So the HAL layer and the application must handle the date in software and to survive resets of the processor the date must in some way be saved in nonvolatile memory.

The HAL layer as it is used in STM32Duino does not support date saving across STOP and STANDBY.
Quote from stm32f1xx_hal_rtc in the STM32duino distribution
(+) Date is saved in SRAM. Then, when MCU is in STOP or STANDBY mode, date will be lost.
User should implement a way to save date before entering in low power mode (an
example is provided with firmware package based on backup registers)
This is not a bug, its an early version of the RTC hardware and this is how it works.
Perhaps you can locate the example mentioned in the HAL quote above.
saeed144
Posts: 36
Joined: Mon Sep 21, 2020 10:11 am

Re: STM32F1xx RTC date problem

Post by saeed144 »

ag123 wrote: Mon Nov 16, 2020 3:37 pm
saeed144 wrote: Sun Nov 15, 2020 3:53 pm You mean there is no solution? :cry:
connect VBAT to a 3v coin cell, keeps time for a long time
it keeps only time not date
saeed144
Posts: 36
Joined: Mon Sep 21, 2020 10:11 am

Re: STM32F1xx RTC date problem

Post by saeed144 »

mlundin wrote: Mon Nov 16, 2020 4:13 pm The STM32F1xx RTC only has one register that normally counts seconds, using the count of seconds modulo 86400 (number of seconds in a day) it can keep track of the time of day, when this count gets larger than 86400 we know that one day has passed. There is no information in the RTC hardware about the what day, date, year and month. So the HAL layer and the application must handle the date in software and to survive resets of the processor the date must in some way be saved in nonvolatile memory.

The HAL layer as it is used in STM32Duino does not support date saving across STOP and STANDBY.
Quote from stm32f1xx_hal_rtc in the STM32duino distribution
(+) Date is saved in SRAM. Then, when MCU is in STOP or STANDBY mode, date will be lost.
User should implement a way to save date before entering in low power mode (an
example is provided with firmware package based on backup registers)
This is not a bug, its an early version of the RTC hardware and this is how it works.
Perhaps you can locate the example mentioned in the HAL quote above.
Thank you
Post Reply

Return to “General discussion”