3 Replies Latest reply on Mar 1, 2019 5:57 AM by KoM_2154881

    BCM20737S RTC clock and setReferenceTime




      I am working with BCM20737S and I am using an external 32K crystal.

      I am able to set the device to deep sleep and keep the clock running. My code follows the rtc_sample code and it is working fine for the basic case.

      The workflow of the system regarding the clock  creates an issue which I am not sure if I understand correctly.


      - So, when the device boots it has  a reference time of 2010. Going in and out of deep sleep everything works fine and the time remains correct.


      - The system is designed so that the actual time is provided by an external device via the time characteristic. When that happens the time changes

      to the current time. The time is set using the rtc_setRTCTime function. So, the correct time is provided to the system after N seconds.

      The given time is stored in the NVRAM and will be used as reference time for the next time the system gets out of deep sleep.


      - After that when the device goes out of deep sleep and calls the rtc_setReferenceTime the new time is off by N seconds, which is the time the clock was running before

      it get the new time. I have to subtract the same N seconds every time a new time is set by the host, after that.


      To solve this issue, I store the difference in seconds N and correct the reference time every time a new time is set. This is working but

      I am wondering if there is a more straightforward way to reset the rtc_clock so I won't have to go to all this trouble. Maybe, I am missing something obvious here.


      Let me know what you think,