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

Retain 32 bits across a watchdog reset ?

I'm sure the same question has been asked in a few different forms, but hoping for some ideas. . . Is there a way to retain 32 bits of information across a watchdog reset ?

I currently use PPI to clock a 32 bit counter at 1Hz from the RTC, this is nice because it gives me a real time clock time in a 32 bit register that runs in low power mode (why oh why is the rtc timer not 32bit ?!?!?!?! or at least has a 32 bit prescaler)

Anyway, the problem with this is that a watchdog reset clears the peripherals, so I lose the 32 bit count. I could write the value to NVM in the watchdog event handler, as long as the flash memory was erased at program startup otherwise it would take too long, but this doesn't seem like an elegant solution.

I know that the ram is not specifically reset, but may be corrupted, to this is also a possibility I guess.

Any suggestions appreciated! Thanks

Parents
  • Update . . . storing to ram before a watchdog reset seems to work well. I've got some guard uint32_t variables around the value I care about, so at least in theory I should be able to detect ram corruption, but it seems the chances of ram corruption with a normal watchdog reset are pretty low. For a brownout or power on reset I clear the variables anyway, so not too concerned about that.

    Our devices update their real time every time they make a BLE connection (usually daily) anyway, so not too worried about keeping great time, in practice 20ppm over a year would be a fantastic result.

    Thanks for your input and advice AmbystomaLabs and Daniel Wang.

Reply
  • Update . . . storing to ram before a watchdog reset seems to work well. I've got some guard uint32_t variables around the value I care about, so at least in theory I should be able to detect ram corruption, but it seems the chances of ram corruption with a normal watchdog reset are pretty low. For a brownout or power on reset I clear the variables anyway, so not too concerned about that.

    Our devices update their real time every time they make a BLE connection (usually daily) anyway, so not too worried about keeping great time, in practice 20ppm over a year would be a fantastic result.

    Thanks for your input and advice AmbystomaLabs and Daniel Wang.

Children
No Data
Related