3 Replies Latest reply on May 2, 2016 5:43 PM by clrac_2121416 Branched from an earlier discussion.

    Resetting RTC internal counter (con't)

      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?

        • 1. Re: Resetting RTC internal counter (con't)

          Hi clrac_2121416,


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



          • 2. Re: Resetting RTC internal counter (con't)


            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:



                 /// 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




            WITH THIS:

                           UINT8 LHL_CTL_RTC_ENABLE              = 1;

                           UINT8 LHL_CTL_RTC_DISABLE             = 0;



            AND REPLACE:

                 /// RTC HW control bits.



                      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;





            void rtc_deinit( void ){

                   LHL_CTL_32K_OSC_POWER_UP = 0x00;

                   LHL_CTL_RTC_ENABLE = 0;





            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.



            1 of 1 people found this helpful
            • 3. Re: Resetting RTC internal counter (con't)

              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.