Skip to main content
paker earth
Associate II
January 30, 2017
Question

RTC display wrong time on STM32L476RG

  • January 30, 2017
  • 1 reply
  • 690 views
Posted on January 30, 2017 at 18:10

Hi all:

I used the device as a data logger, wake up from shutdown mode if the nucleo RTC alarm goes off on 29 minute every hour.

But it seems  the system RTC display wrong time before the device enters shutdown mode.

So I use one I2C DS3231 RTC module as reference.

And the I2C RTC is the same.

Here are some snippet.

It looks fine at the beginning.

 0690X00000606BdQAI.png

0690X000006068kQAA.png

At the end

No matter system rtc or i2c rtc displayed the wrong time.

But another acquisition can start on the right time, display right time infomation.

0690X00000606BnQAI.png0690X00000606BiQAI.png0690X00000606BsQAI.png

Attachments are source file and log file.

Could someone tell me how to fix it?

Thank you all in advance. 

#stm32l476rg
This topic has been closed for replies.

1 reply

waclawek.jan
Super User
January 30, 2017
Posted on January 30, 2017 at 22:22

At least 2 issues:

STM32L486xx HAL User Manual: Initialization and de-initialization functions

         (#) To read the calendar through the shadow registers after Calendar

             initialization, calendar update or after wakeup from low power modes

             the software must first clear the RSF flag. The software must then

             wait until it is set again before reading the calendar, which means

             that the calendar registers have been correctly copied into the

             RTC_TR and RTC_DR shadow registers. The HAL_RTC_WaitForSynchro() function

             implements the above software sequence (RSF clear and RSF check).

STM32L486xx HAL User Manual: RTC Time and Date functions

Note:

You must call after to unlock the values in the higher-order calendar shadow registers to ensure consistency between the time and date values. Reading RTC current time locks the values in calendar shadow registers until Current date is read.

I don't Cube so I won't help with fixing this.

JW