This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Retained value despite of chip reset

Hi! 

I am using SDK15 and I try to implement a clock feature. I have found some information about nRF52832, that RTC isn't a real time clock but a counter instead and it does not preserve its value through resets. 

My application uses many alarms that ring when the time comes. :)  To make them work I need some kind of independent timer running all the time, for example in epoch unix format (uint32_t seconds). With 32kHz RTC1 and PRESCALER = 4095 I am able to count up to like 24 days before buffer overflow but I would rather stop and start again my main timer every 7 days or 24 hours, doesn't really matter now. 

Sometimes something bad may happen, a hard reset, a failure leading to crash and reset and so on. Is there a way I can retain my timer value? Suppose I don't know when the reset may happen, so I won't be able to save its value in flash memory just before (saving the value every second isn't an option, increased energy consumption and flash may wear out). I can't use any external clock module. Sending actual timer value to connected peer in case of crash/reset and getting it back afterwards is just too complicated and not reliable - there may be no peers connected.

Is there some kind of register where can I store some data to persist through resets? Or any other way to achieve what I try to accomplish? If it is important my device is battery powered.

Thanks

Parents
  • Hi,

    I am afraid that there is no silver bullet for what you are trying to achieve.

    As you write, the RTC is a counter, not a clock (although the abbreviation might at first suggest that.) You are correct that keeping the time should be no problem as long as the SoC is not reset. (For instance by counting seconds, or minutes, and keeping the time in RAM.)

    The RTC gets reset on all resets, so in any case you will lose precision on reset. Whether or not RAM is retained depends on reset source. See Reset behavior.

    What it means in practice is that, in order to keep track of time past a reset, you need to do one of the things that you write that you cannot do: Either use an external clock module, or set the time from an external device after the reset.

    The only way to store values through a reset is either by flash, or, if the reset source allows for it, to use RAM, possibly with RAM retention.

    Regards,
    Terje

Reply
  • Hi,

    I am afraid that there is no silver bullet for what you are trying to achieve.

    As you write, the RTC is a counter, not a clock (although the abbreviation might at first suggest that.) You are correct that keeping the time should be no problem as long as the SoC is not reset. (For instance by counting seconds, or minutes, and keeping the time in RAM.)

    The RTC gets reset on all resets, so in any case you will lose precision on reset. Whether or not RAM is retained depends on reset source. See Reset behavior.

    What it means in practice is that, in order to keep track of time past a reset, you need to do one of the things that you write that you cannot do: Either use an external clock module, or set the time from an external device after the reset.

    The only way to store values through a reset is either by flash, or, if the reset source allows for it, to use RAM, possibly with RAM retention.

    Regards,
    Terje

Children
No Data
Related