Know if a watchdog reset has tripped - SOLVED
I'm using the Adafruit_SleepyDog library, and would be nice at powerup to know if a watchdog reset has occoured.
It's possible?
I answer to my own question:
The same library that check the watchdog can read the MCU registry RCAUSE register..
[code]
#include <Adafruit_SleepyDog.h>
uint8_t resetCause = 0;
SerialUSB.print(F("Last reboot reason : "));
resetCause = Watchdog.resetCause();
if (bitRead(resetCause,0)) { //Power-on-reset
SerialUSB.println(F("Power-on-reset"));
} else if (bitRead(resetCause,1)) { //Brown-out-detect BOD12
SerialUSB.println(F("Brown-out-detect BOD12"));
} else if (bitRead(resetCause,2)) { //Brown-out-detect BOD33
SerialUSB.println(F("Brown-out-detect BOD33"));
} else if (bitRead(resetCause,4)) { //External reset
SerialUSB.println(F("External reset"));
} else if (bitRead(resetCause,5)) { //Watchdog reset
SerialUSB.println(F("Watchdog reset"));
} else if (bitRead(resetCause,6)) { //System reset
SerialUSB.println(F("System reset"));
}
Little update, seem that the function not give the correct value as i read always as reason a "system reset". Need to investigate why.
Hi @Aaron, the solution is the Watchdog.resetCause(). But i'm not sure that it works as it should as by now i've always seen "System reset" as a reboot cause... I've checked the Adafruit_SleepyDog.h code ad it check the correct register, so i need to made some more tests.
Your answer
Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!
Keep Informed
About This Forum
This community is for professionals and enthusiasts of our products and services.
Read GuidelinesQuestion tools
Stats
Asked: 12/25/20, 7:59 PM |
Seen: 1481 times |
Last updated: 1/4/21, 1:24 AM |
Did you get this sorted? What is the solution?