RTC VBAT MODE

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

Hi,

I am using SN8205, SDK V3.2.1.

How to make RTC time maintained between reboots?

Reboot is only VDD cutoff, VBAT will always be powered.

Regards,

Karthik

0 Likes
1 Solution
Anonymous
Not applicable

A patch may help overcome this issue to some extent.

Here is the algorithm -

  1. Store the powersave state(enabled/disabled) of CPU in RTC Backup Registers.
  2. After reboot, in the init sequence, check the backup resistors to determine the last known state of CPU during the shutdown.
  3. If the state was powersave disable, the RTC was ticking at 1Hz, so no action needed and the time will be correct.
  4. If the state was powersave enabled, the RTC was ticking at 800Hz, need to recompute correct time using the existing functions convert_rtc_calendar_values_to_units_passed() and add_1p25ms_contribution().

View solution in original post

0 Likes
6 Replies
Anonymous
Not applicable

To keep RTC time you may need to:

- Cold boot/power loss => Only if info is also kept in NV RAM.

- Warm reboot/Soft rest => Either in NV RAM or your initialization code does not re-initialize the RAM variables (so RAM values are automatically retained).

I hope this helps.

Cheers,

Gil

0 Likes
Anonymous
Not applicable

In my setup, I have two power source, one supplying VDD and the other for VBAT. The VDD can be cut off any time.

Could you indicate which NVRAM variable should not be reinitialized during cold boot, so that the RTC time is retained?

Do you have code snippet?

I am also using MCU Powersave, and can see its implementation is based on RTC sourced from LSE.

0 Likes
Anonymous
Not applicable

I don't have code snippet, but you just need to #define some locations between 0x10 and 0x6F (96 bytes) and store it there, and after the reboot get it from there.  This is the SDK API:

bleprofile_ReadNVRAM(DEF_LOCATION, value, &data);

And there is a write function as well, etc.

0 Likes
Anonymous
Not applicable

The requirement is to retain the RTC Timestamp across reboots. I am using the WiFi SDK V3.1.2.

My issue was the RTC was not retaining the timestamp correctly across reboots. The time was advancing a lot faster. For eg, if the system was cold boot over 10 second. After reboot it would show the time was advanced by 1 hour.

I have gone through the code and see the issue in implementation of Powersave. Powersave uses RTC Alarm. During powersave, the RTC clock frequency is changed from 1Hz to 800Hz. So if we switch off Vdd during powersave, the RTC is ticking at 800Hz, that cause the time to advance faster.

Anonymous
Not applicable

I see.  Interesting issue.

0 Likes
Anonymous
Not applicable

A patch may help overcome this issue to some extent.

Here is the algorithm -

  1. Store the powersave state(enabled/disabled) of CPU in RTC Backup Registers.
  2. After reboot, in the init sequence, check the backup resistors to determine the last known state of CPU during the shutdown.
  3. If the state was powersave disable, the RTC was ticking at 1Hz, so no action needed and the time will be correct.
  4. If the state was powersave enabled, the RTC was ticking at 800Hz, need to recompute correct time using the existing functions convert_rtc_calendar_values_to_units_passed() and add_1p25ms_contribution().
0 Likes