Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: main.cpp
- Revision:
- 10:0edd1ab03f84
- Parent:
- 9:5d1d36c2664f
- Child:
- 11:e697f0c49466
--- a/main.cpp Thu Mar 26 11:02:19 2020 +0000
+++ b/main.cpp Thu Apr 02 18:01:13 2020 +0000
@@ -1,11 +1,14 @@
#include "mbed.h"
#include "wdt.h"
-// Watchdog with better fault coverage
+// Lab 6
// ---------------------------------
// * Three threads co-operate to flash two LEDs
// * A simple way to inject a fault, by pressing a button
// * The watchdog is configured with a 1024ms timeout
-// * If hardware fails, set flag to trigger watchdog so it resets the system
+// * To kick the watchdog, both LED threads must set a signal that is received by another thread which kicks it
+// * If hardware fails, turn on red on-board LED.
+
+//This code was tested, since I had the KL25Z available
#define ON 1
#define OFF 0
@@ -118,7 +121,7 @@
volts=volts*3.3;
volts2=anin.read()*3.3;
//Voltage with LEDs on is around 1.2V, since the resistances available were not of 680ohms.
- if (volts>1.5 || volts2>1.5){redled=0;}//Set a signal to detect fault
+ if (volts>1.5 || volts2>1.5 || volts<0.5 || volts2<0.5){redled=0;}//Turn on on-board LED
}
//printf("volts: %f volts 2: %f", volts, volts2);//Debugging
volts=0; volts2=0;