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

How to recover calendar data after a reset

Dear Nordic Developer Zone,

I have implemented a real-time-clock using application timer which is based on the on-chip real-time counter on NRF51822.

A concern of mine is that after a reset due to a unpredictable error( i.e. stack error), is there a way to recover the previous time information?

Thanks, Tony

Parents Reply Children
  • I would add a caveat to writing the time to flash: We don't know Tony's time accuracy requirement which would dictate how often he needs to save the time. If the time needs to be saved frequently, flash wear would be important. He may need to rotate the saved time through a large set of flash locations to prevent wearing out a single location. He'd also need a way to locate the latest time in flash after a reset. That might be simple if the time was something like a seconds since epoch counter.

  • Are the RAMs really zeroed on reset or is it just an issue that the behavior is undefined? If the ram doesn't really have a global reset you might be able to stick the current time and a crc in ram someplace and at least have a chance at recovering the current time. I've done this with DRAM (filled one page with the data we wanted to keep and a 64bit CRC, repeated over and over) the data could often survive for 10s of seconds with a complete power loss. DRAM != SRAM, but it might be something to try.

  • I agree on John's point of view of wearing flash too quick if keep saving it in a fix location. I haven't tried out what's RAM behavior after a reset but I think Clem's approach is worth trying.

Related