Closed paulporto closed 2 years ago
this person make it work with mbed. i dont understand the code but i will paste it here in case some one find it useful http://embedded-lab.com/blog/stm32s-internal-rtc/ https://libstock.mikroe.com/projects/view/1742/stm32-s-internal-rtc
i think it may be related to this:
The epoch includes date data which is lost on power cycle on stm32f1xx boards, this should be fixed by my pull request here
The epoch includes date data which is lost on power cycle on stm32f1xx boards, this should be fixed by my pull request here
i try your version of this library, still same behaviour
i just realize that i have to replace the rtc.c and rtc.h files in the cores. everything its working now thank you very much.
I've just hit exactly this problem. I had a development (a Bluepill STM32F103C8T6 based satellite clock) based on the Roger Clark STM32 core.
It used the RTC in the backup domain, that is clock source LSE, with a super cap on Vbat.
With the following library, the time survived power cycles without being reset : https://github.com/rogerclarkmelbourne/Arduino_STM32/blob/master/STM32F1/libraries/RTClock/src/RTClock.h
After migrating some time later to the official STM32 arduino core 1.9.0 and adapting the clock to use the STM32RTC library https://github.com/stm32duino/STM32RTC , the time would not be retained during a power cycle.
Anyway, I have applied the fix here, developed by Josh-Gaby and it now appears to work correctly again. That is, the RTC time does not suffer an unwanted reset during a power cycle.
Many thanks for fixing that!
This is what I did to apply the fix, in case it is useful for someone who wants to retrofit it into the current arduino core version 1.9.0 :
Removed just the src directory from the locally downloaded STM32RTC library e.g. ..../Arduino/libraries/STM32duino_RTC and replaced it with the src directory obtained from https://github.com/josh-gaby/STM32RTC
disabled any restrictions, requiring core release > 1.9.0 from the files in the source directory above. These are of the form: && (STM32_CORE_VERSION > 0x01090000)
deleted rtc.h from e.g. ..../ArduinoData\packages\STM32\hardware\stm32\1.9.0\cores\arduino\stm32
deleted rtc.c from e.g. ..../ArduinoData\packages\STM32\hardware\stm32\1.9.0\libraries\SrcWrapper\src\stm32
deleted the include entry for rtc.h from e.g. ....\ArduinoData\packages\STM32\hardware\stm32\1.9.0\cores\arduino/board.h
I don't doubt there is a more elegant way of achieving the same thing, but it worked for me. I'm looking forward to the next core release when these changes (or similar) will be rolled in.
I've just hit exactly this problem. I had a development (a Bluepill STM32F103C8T6 based satellite clock) based on the Roger Clark STM32 core. It used the RTC in the backup domain, that is clock source LSE, with a super cap on Vbat. With the following library, the time survived power cycles without being reset : https://github.com/rogerclarkmelbourne/Arduino_STM32/blob/master/STM32F1/libraries/RTClock/src/RTClock.h
After migrating some time later to the official STM32 arduino core 1.9.0 and adapting the clock to use the STM32RTC library https://github.com/stm32duino/STM32RTC , the time would not be retained during a power cycle.
Anyway, I have applied the fix here, developed by Josh-Gaby and it now appears to work correctly again. That is, the RTC time does not suffer an unwanted reset during a power cycle.
Many thanks for fixing that!
This is what I did to apply the fix, in case it is useful for someone who wants to retrofit it into the current arduino core version 1.9.0 :
1. Removed just the src directory from the locally downloaded STM32RTC library e.g. ..../Arduino/libraries/STM32duino_RTC and replaced it with the src directory obtained from https://github.com/josh-gaby/STM32RTC 2. disabled any restrictions, requiring core release > 1.9.0 from the files in the source directory above. These are of the form: && (STM32_CORE_VERSION > 0x01090000) 3. deleted rtc.h from e.g. ..../ArduinoData\packages\STM32\hardware\stm32\1.9.0\cores\arduino\stm32 4. deleted rtc.c from e.g. ..../ArduinoData\packages\STM32\hardware\stm32\1.9.0\libraries\SrcWrapper\src\stm32 5. deleted the include entry for rtc.h from e.g. ....\ArduinoData\packages\STM32\hardware\stm32\1.9.0\cores\arduino/board.h
I don't doubt there is a more elegant way of achieving the same thing, but it worked for me. I'm looking forward to the next core release when these changes (or similar) will be rolled in.
Thanks! This method works on my custom STM32F103 circuit with supercap connected to VBAT pin.
Btw, for Windows user, the ArduinoData is located at "%USERPROFILE%\AppData\Local\Arduino15"
I've just hit exactly this problem. I had a development (a Bluepill STM32F103C8T6 based satellite clock) based on the Roger Clark STM32 core. It used the RTC in the backup domain, that is clock source LSE, with a super cap on Vbat. With the following library, the time survived power cycles without being reset : https://github.com/rogerclarkmelbourne/Arduino_STM32/blob/master/STM32F1/libraries/RTClock/src/RTClock.h
After migrating some time later to the official STM32 arduino core 1.9.0 and adapting the clock to use the STM32RTC library https://github.com/stm32duino/STM32RTC , the time would not be retained during a power cycle.
Anyway, I have applied the fix here, developed by Josh-Gaby and it now appears to work correctly again. That is, the RTC time does not suffer an unwanted reset during a power cycle.
Many thanks for fixing that!
This is what I did to apply the fix, in case it is useful for someone who wants to retrofit it into the current arduino core version 1.9.0 :
- Removed just the src directory from the locally downloaded STM32RTC library e.g. ..../Arduino/libraries/STM32duino_RTC and replaced it with the src directory obtained from https://github.com/josh-gaby/STM32RTC
- disabled any restrictions, requiring core release > 1.9.0 from the files in the source directory above. These are of the form: && (STM32_CORE_VERSION > 0x01090000)
- deleted rtc.h from e.g. ..../ArduinoData\packages\STM32\hardware\stm32\1.9.0\cores\arduino\stm32
- deleted rtc.c from e.g. ..../ArduinoData\packages\STM32\hardware\stm32\1.9.0\libraries\SrcWrapper\src\stm32
- deleted the include entry for rtc.h from e.g. ....\ArduinoData\packages\STM32\hardware\stm32\1.9.0\cores\arduino/board.h
I don't doubt there is a more elegant way of achieving the same thing, but it worked for me. I'm looking forward to the next core release when these changes (or similar) will be rolled in.
I do not know how to make the choice, there is no response from the official?
the time its lost after power cycling, although LSE_CLOCK is selected, and the vbat is connected im using the epoch example with some modifications to be able to the set time via UART
arduino 1.8.13 stm32f103 bluepill library.properties: name=STM32duino RTC version=1.1.0 author=STMicroelectronics, Wi6Labs maintainer=stm32duino ........