This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Retaining RTC Time After resetting NRF52840.

Hello Respected members, I have a question regarding the #nrf5-calendar example that is, is there any way to retain the NRF52 time after resetting the device. I am using the nrf_calendar example which is using RTC0 and when I reset the device the time is no longer retained ( which I have set from the GUI). Now my question is, is there any way to retain the time even after resetting the device, should I go for app_timer instead of RTC, or do I have to store the time in flash which holds the values after reset. If flash is the solution then kindly elaborate how would I save time values in flash.
Thanks and regards
Engr. Sami Ul Haq

  • Hello Sami Ul Haq,

    Sami Ul Haq said:
    I am not talking about the SYSTEM_OFF MODE, the device will be in SYSTEM_ON MODE where the RTC will be running

    Aha - then I have misunderstood you, I thought you were talking about the device being in SYSTEM_OFF mode.
    The RTC will keep running while the device is in SYSTEM_ON mode, no problem. It will have no issue keeping the time as long as it stays in SYSTEM_ON sleep mode.

    Sami Ul Haq said:
    but I am confused about the Reset from the button(Whether RTC stopped or not). 

    The RTC counter will be reset if the device is reset, yes. As you can see in the COUNTER register documentation it is set to 0x0 upon reset.

    Sami Ul Haq said:
    Also can you please elaborate the all possible reset behaviours of NRF52840?

    What exactly would you like me to elaborate on? You can read about the device's reset behavior in the Reset documentation.

    Best regards,
    Karl

  • Hello Karl Sir,

    Thank you so much for a thorough explanation. But sir I am a little confused about where the time is being stored when setting it from GUI, I mean that when I set time from GUI and then RTC start incrementing after every second, then where these values are stored and whether these values will also be cleared whenever there is RESET from a button. 

    Kind regards,

    Sami Ul Haq

  • Sami Ul Haq said:
    Thank you so much for a thorough explanation.

    No problem at all, I am happy to help!

    Sami Ul Haq said:
    I mean that when I set time from GUI and then RTC start incrementing after every second, then where these values are stored and whether these values will also be cleared whenever there is RESET from a button. 

    During normal operation the incrementing RTC value will be stored in the COUNTER register of the RTC peripheral that I just linked you. So the counter value will be lost unless it is stored somewhere else that is persistent, like in Flash, however writing to flash every second will cause excessing flash wear over time, so it might not be a feasible solution either.

    Best regards,
    Karl

  • Sami Ul Haq,

    I got it, You are amazing Sir. For now, my concept is cleared. If there is any other doubt with the passage of time I will let you know. Please respond to my reply whenever there are any other questions. 

    Again thank you so much. 

    Kind Regards,

    Sami Ul Haq

  • Sami Ul Haq said:
    I got it, You are amazing Sir.

    Thank you for saying so!

    Sami Ul Haq said:
    For now, my concept is cleared. If there is any other doubt with the passage of time I will let you know.

    I am glad to hear that it is now clear. Please do not hesitate to open another ticket if you should encounter any issues or questions in the future.

    Good luck with your development!

    Best regards,
    Karl

Related