Test program for watchdog timer library. LED will flash for 5 seconds then simulate a hard fault. Watchdog timer will timeout after 3 seconds and reset the system.

Dependencies:   WatchdogTimer mbed

Files at this revision

API Documentation at this revision

Comitter:
jcady92
Date:
Tue Jun 30 16:45:14 2015 +0000
Commit message:
Test program for the watchdog timer library. Flashes LED for 5 seconds, then simulates a hard fault. Watchdog timer will kick in and reset the system 3 seconds after hard fault.

Changed in this revision

WatchdogTimer.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/WatchdogTimer.lib	Tue Jun 30 16:45:14 2015 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/users/jcady92/code/WatchdogTimer/#10fdcb411fbd
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Tue Jun 30 16:45:14 2015 +0000
@@ -0,0 +1,32 @@
+#include "mbed.h"
+#include "WatchdogTimer.h"
+
+DigitalOut led(LED1);
+WatchdogTimer watchdogTimer(3); //Watchdog timer with 3 second timeout
+
+int main()
+{
+    Timer timer;
+    timer.start();
+    
+    //NOTE: Ensure your main loop operations don't take longer than the watchdog timeout you set
+    while(1)
+    {
+        //Flash LED for five seconds
+        if (timer.read_ms() < 5000)
+        {
+            led = 1;
+            wait(0.2);
+            led = 0;
+            wait(0.2);
+        }
+        else
+        {
+            //Simulate hard fault
+            while(1) {}
+        }
+        
+        //Kick the watchdog to reset its timer
+        watchdogTimer.kick();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Tue Jun 30 16:45:14 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/7cff1c4259d7
\ No newline at end of file