Capture early warnings WDT interrupt

Hello,

Can you please recommend a better way (if there is one) to capture the early warnings WDT interrupt inside the sketch than to copy the function “WDT_Handler” from the Sodaq_wdt library and comment it out from the original library?

Thank you,
Ionel

Hi Ionel,

There is no better way, this function name is hardcoded to this specific name. I recommend not changing this as it’s standardized. Instead, could you perhaps provide some more information what you want to achieve?

Regards,
Thom

Hi Thom,

What we are trying to do is:

  • avoid loosing some time series statistics, which we are computing in RAM, if the system is reset by the watchdog, and
  • avoid abusing the flash by writing to it only when absolutely necessary.

In this respect we are trying to use the writing to flash just in case we need to protect the computation data (averages, min, max for parameters over certain periods of time). We kick the dog quite often, and we have chosen to write to flash only when the Early Warning WDT Interrupt is coming.

Can you suggest a better strategy?

Thank you,
Darius

Hi Darius,

For that purpose it is OK. I’m not a big fan of doing a lot in interrupts, but the situation you sketch is a good example of when it can be fine to do so.

If you want an alternative option, you could look into “preserving” some RAM upon reset. It’s a lot nicer as you won’t have to wear your flash, depending on how often you’re expecting this to happen.
In that case writing your statistics to a reserved location in the RAM upon early warning would be preferable. This, of course, assumes there is no power cycling.

But, as I said before, your option is fine too. Just don’t do it too often.
I’m not exactly sure what the problem is then?

Regards,
Thom

Thank you very much, Thom! We learned something new (the fact that some info stored in RAM can be kept during a reset which does not cut the power).
Regards,
Darius / Ionel