Resetting RTC internal counter (con't)

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

cross mob
Anonymous
Not applicable

Adding to this discussion: Resetting RTC internal counter

Can I safely say that the internal RTC Counter is not reset unless there is a signal on RESET_N, a disruption in power, or a watch_dog timer expiration?  Also, can I safely say (write), that the RTC Counter cannot be bumped or changed, and that once it is reset, you can modify your reference time forward, but not the counter?

0 Likes
3 Replies
JacobT_81
Employee
Employee
250 replies posted 100 replies posted 50 replies posted

Hi cliff@rayman.com​,

You are correct, the application level provides no way of disabling the RTC hardware once it is initialized.

Jacob

0 Likes
JacobT_81
Employee
Employee
250 replies posted 100 replies posted 50 replies posted

cliff@rayman.com

Despite the lack of a deinit function, there may one approach you can take to disable the RTC without the need for a patch.

By changing some variables to reflect invalid values and recalling the rtc_init function, the hardware will be disabled.

---------------------------------------------------------------------------------

In rtc.h:

REPLACE:

     /// RTC enable type.

     typedef enum

     {

               // enable RTC and power up 32kHz crystal oscillator

               LHL_CTL_RTC_ENABLE              = 1,

               // disable RTC and power down the 32kHz crystal oscillator

               LHL_CTL_RTC_DISABLE             = 0

     }tRTC_LHL_CTL_RTC_ENABLE_MODE;

WITH THIS:

               UINT8 LHL_CTL_RTC_ENABLE              = 1;

               UINT8 LHL_CTL_RTC_DISABLE             = 0;

AND REPLACE:

     /// RTC HW control bits.

     enum

     {

          LHL_CTL_32K_OSC_POWER_UP = 0x04,

          LHL_CTL_32K_OSC_POWER_DN = 0x00,

          LHL_CTL_32K_OSC_POWER_MASK = 0x04

     };

WITH THIS:

     UINT8    LHL_CTL_32K_OSC_POWER_UP = 0x04;

     UINT8    LHL_CTL_32K_OSC_POWER_DN = 0x00;

     UINT8    LHL_CTL_32K_OSC_POWER_MASK = 0x04;

--------------------------------------------------------------------------------

Your app:

#include "rtc.h"

void rtc_ininit( void ){

       LHL_CTL_32K_OSC_POWER_UP = 0x04;

       LHL_CTL_RTC_ENABLE = 1;

       rtc_init();

}

void rtc_deinit( void ){

       LHL_CTL_32K_OSC_POWER_UP = 0x00;

       LHL_CTL_RTC_ENABLE = 0;

       rtc_init();

}

This will disable the hardware, but will produce some untested/undefined behavior. The counter should reset, but my testing has been very limited on this. Many previously defined value will remain unless you go through and redefine.

Jacob

Anonymous
Not applicable

Hi Jacob,

Appreciate the response.  I should have been more clear.  I was trying to advance the counter so that instead of 0, it was guaranteed to be greater than the value that I save in NVRAM directly before going to DEEP SLEEP.  Made some of my programming easier.  I don't believe there is an easy way to do that, so I just set a flag that my App picks up on, and then the App sends down the approrpriate info.

Thanks!

Cliff

0 Likes