Skip to content

Detecting the reset cause in Arduino on SAMD21 based boards

Notifications You must be signed in to change notification settings

gjt211/SAMD21-Reset-Cause

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 

Repository files navigation

SAMD21-Reset-Cause

Detecting the reset cause in Arduino on SAMD21 based boards

I was looking for a way to determine what was the cause of reset on my MKRZero board and without any success the following is what I determined.

You can access a register in Arduino named REG_PM_RCAUSE and you can test it against several values to determine the reset cause.

Example:

if (REG_PM_CAUSE == PM_RCAUSE_SYST){
  Serial.println("Reset requested by system");
}
if (REG_PM_CAUSE == PM_RCAUSE_WDT){
  Serial.println("Reset requested by Watchdog");
}
if (REG_PM_CAUSE == PM_RCAUSE_EXT){
  Serial.println("External reset requested");
}
if (REG_PM_CAUSE == PM_RCAUSE_BOD33){
  Serial.println("Reset brown out 3.3V");
}
if (REG_PM_CAUSE == PM_RCAUSE_BOD12){
  Serial.println("Reset brown out 1.2v");
}
if (REG_PM_CAUSE == PM_RCAUSE_POR){
  Serial.println("Normal power on reset");
}

The register RCAUSE bits are as follows;

1 = PM_RCAUSE_POR.

2 = PM_RCAUSE_BOD12.

4 = PM_RCAUSE_BOD33.

8 = N/A always zero.

16 = PM_RCAUSE_EXT.

32 = PM_RCAUSE_WDT.

64 = PM_RCAUSE_SYST.

128 = N/A always zero.

About

Detecting the reset cause in Arduino on SAMD21 based boards

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published