In general there are at least 3 different ways a reset can occur and the setup() routine be called
-Power on
-Watchdog fired
-Wake after deep sleep.
Using the MKRWAN1310 board is there any method of finding out which of the above occurred?
In general there are at least 3 different ways a reset can occur and the setup() routine be called
-Power on
-Watchdog fired
-Wake after deep sleep.
Using the MKRWAN1310 board is there any method of finding out which of the above occurred?
Hi @rw950431
It's possible to determine which reset occured using the SAMD21's RCAUSE register:
// Check the RCAUSE register reset bits
void setup()
{
Serial.begin(115200); // Initialise the native USB port
while (!Serial); // Wait for the console to open
Serial.print(F("SYST: "));
Serial.println(PM->RCAUSE.bit.SYST); // System (software) reset
Serial.print(F("WDT: "));
Serial.println(PM->RCAUSE.reg & PM_RCAUSE_WDT); // Watchdog timer reset (use of WDT bit causes compilation error)
Serial.print(F("EXT: "));
Serial.println(PM->RCAUSE.bit.EXT); // External (reset button) reset
Serial.print(F("POR: "));
Serial.println(PM->RCAUSE.bit.POR); // Power-on reset
Serial.println();
}
void loop() {}
The RCAUSE register also includes brown out detection bits: BOD33 and BOD12.
Thanks @MartinL exactly what I wanted.
Knowing the keywords enabled me to also find
https://microchipdeveloper.com/32arm:samd21-pm-overview
Which were of interest to me also
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.