Skip to main content
HAbay.1
Associate III
August 16, 2021
Solved

Can you write values to the RTC counter registers(RTC_CNTL/RTC_CNTH) after you've set them to an intial value?

  • August 16, 2021
  • 2 replies
  • 1395 views

I've been trying to implement a clock and calendar into my solar tracker project(using an stm32f103) so that I can set at which time it should go to sleep ( and for how long) , but every time the board goes into standby the counter -unfortunately- gets reset. To counter act that, I tried writing the values of the counter register into the backup registers (which worked just fine) writing these values back to the counter registers turned out to be quite a hassle however, and it just never seemed to work for me. I did disable the write protection and enabled the CNF bit mind you, but their values just wouldn't change .

    This topic has been closed for replies.
    Best answer by HAbay.1

    I solved this issue by turning off the LSE first (RTC clock) before modifying the value of the counters. I noticed that when i was modifying the values of the counter it just resets them so it had to be that , and it was fortunately!

    2 replies

    TDK
    Super User
    August 16, 2021

    From the reference manual:

    To write to this register it is necessary to enter configuration mode (see Section 18.3.4: Configuring RTC registers).

    Did you do that?

    Next time please include the chip number in your post.

    "If you feel a post has answered your question, please click ""Accept as Solution""."
    HAbay.1
    HAbay.1Author
    Associate III
    August 16, 2021

    yes, I did and the chip is the f103

    HAbay.1
    HAbay.1AuthorBest answer
    Associate III
    August 17, 2021

    I solved this issue by turning off the LSE first (RTC clock) before modifying the value of the counters. I noticed that when i was modifying the values of the counter it just resets them so it had to be that , and it was fortunately!