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
Revision 0:882d720a2cc6, committed 2015-06-30
- 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
diff -r 000000000000 -r 882d720a2cc6 WatchdogTimer.lib --- /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
diff -r 000000000000 -r 882d720a2cc6 main.cpp --- /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(); + } +}
diff -r 000000000000 -r 882d720a2cc6 mbed.bld --- /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