WatchdogTimer Library for Arduino Zero: WDTZero

WatchdogTimer Library for Arduino Zero: WDTZero

Making an IoT project, but tired of stalled web and server-access times. This WDT serves hardware and software reliability you looking for.

  • 835 views
  • 1 comment
  • 2 respects

Components and supplies

About this project

WDTZero.h - Library for Watchdog on the SAM D Zero Series

See ATSAMD2x datasheet, #18, page205 onwards

Defines Watchdog Calss to Setup Watchdog timer in Normal mode with EarlyWarning interrupt.

1. Sets Hardware WDT timer

  • -> for stalled processor situations, generates a reset
  • -> 4, 8 or 16 seconds response

2. Sets Software WDT using EarlyWarning timer (EWT) and software counter (Global Variable)

  • -> for stalled software, generates a reset if software loop does not clear WDT on time
  • -> EWT runs on 0.5 Sec interval ISR
  • -> Total soft-WDT intervals are 4, 8, 6, 32 Seconds, 1, 2, 4, 10 Minutes

Code

WDTZero DemoC/C++
Arduini sketch
#include <WDTZero.h>

byte wdtCounter, wdtCounterReset;
WDTZero MyWatchDoggy(WDT_HARDCYCLE4S); // Define WDT with hard-Watchdog @ 4 seconds - hardstop when processor is stalled. Configure your soft-counter at .Setup(). 

void setup() {
  int t = 20; //Initialize serial and wait for port to open, max 10 seconds
  Serial.begin(9600);
  while (!Serial) {
    delay(500);
    if ( (t--) == 0 ) break;
  }
 Serial.print("\nWDTZero-Demo : Setup Watchdog at 16Sec interval"); 
 MyWatchDoggy.setup(WDT_CYCLE16S);  // initialize WDT-softcounter refesh cycle on 16sec interval
}

void loop() {
  unsigned int t = 0;


  Serial.print("\nWatchdog Test1 - loop 30 seconds with a WDT.clear()\n");
  for (t = 1; t < 30; ++t) {
    MyWatchDoggy.clear();  // refresh wdt - before it loops
    delay(950);
    Serial.print(t);Serial.print(".");
  }

  Serial.print("\n\nWatchdog Test2 - Free run wait for reset\n");
  for (t = 1; t < 30; ++t) {
    delay(950);
    Serial.print(t);Serial.print(".");
    }
    
Serial.print("\nYou will never read this line");

}

Comments

Similar projects you might like

Telegram Bot Library

by Arduino_Genuino

  • 49,187 views
  • 19 comments
  • 81 respects

DC Motor Controlling Library

Project tutorial by ambhatt

  • 4,625 views
  • 12 comments
  • 33 respects

8-Bit IO Port Library for Arduino

Project tutorial by ambhatt

  • 2,548 views
  • 4 comments
  • 6 respects

RIMS Arduino Library

Project in progress by franckgaga

  • 1,846 views
  • 2 comments
  • 6 respects

Embedis: Project Keystore Library

by Team thingSoC

  • 1,666 views
  • 1 comment
  • 8 respects
Add projectSign up / Login