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.
Fork of Watchdog_sample_nocoverage by
Revision 6:0da8649c011b, committed 2018-03-09
- Comitter:
- Tobden
- Date:
- Fri Mar 09 23:04:34 2018 +0000
- Parent:
- 5:9817756efc34
- Commit message:
- Lab 6 Code 1 Watchdog Fault Coverage
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
| mbed_app.json | Show annotated file Show diff for this revision Revisions of this file |
diff -r 9817756efc34 -r 0da8649c011b main.cpp
--- a/main.cpp Tue Feb 27 10:29:30 2018 +0000
+++ b/main.cpp Fri Mar 09 23:04:34 2018 +0000
@@ -1,5 +1,5 @@
#include "mbed.h"
-#include "rtos.h"
+//#include "rtos.h"
#include "wdt.h"
// Sample program using the Watchdog
@@ -37,12 +37,13 @@
void led1_thread() { // method to run in thread
osEvent evt ;
while (true) {
+wdt_kickA(); //write the value 0x55 to the Watchdog Register
evt = Thread::signal_wait(0x0); // wait for any signal
if (evt.status == osEventSignal) {
if (evt.value.signals & 0x01) led1 = ON ;
if (evt.value.signals & 0x02) led1 = OFF ;
}
- waitButton() ; // POSSIBLE FAULT HERE
+ // waitButton() ; // POSSIBLE FAULT HERE
}
}
@@ -52,12 +53,13 @@
void led2_thread() { // method to run in thread
osEvent evt ;
while (true) {
+ wdt_kickB(); //write the value 0xAA to the Watchdog Register
evt = Thread::signal_wait(0x0); // wait for any signal
if (evt.status == osEventSignal) {
if (evt.value.signals & 0x01) led2 = ON ;
if (evt.value.signals & 0x02) led2 = OFF ;
}
- // waitButton() ; // POSSIBLE FAULT HERE
+ // waitButton() ; // POSSIBLE FAULT HERE
}
}
@@ -72,7 +74,7 @@
Thread::wait(250) ;
threadLED1.signal_set(0x2) ;
threadLED2.signal_set(0x2) ;
- // waitButton() ; // POSSIBLE FAULT HERE
+ waitButton() ; // POSSIBLE FAULT HERE
}
}
@@ -85,9 +87,8 @@
// ----------------------------------------------
int main(void) {
- wdt_32ms() ; // initialise watchdog - 32ms timeout
- tick.attach_us(callback(&wdt_kick_all), 20000); // ticks every 20ms
-
+ wdt_1sec() ; // initialise watchdog - 1 second timeout
+
// start threads
threadT.start(&timer_thread) ; // start the timer thread
threadLED1.start(&led1_thread) ; // start the LED1 control thread
diff -r 9817756efc34 -r 0da8649c011b mbed_app.json
--- a/mbed_app.json Tue Feb 27 10:29:30 2018 +0000
+++ b/mbed_app.json Fri Mar 09 23:04:34 2018 +0000
@@ -1,7 +1,7 @@
{
"config": {
- "main-stack-size": {
- "value": 2000
+ "thread-stack-size": {
+ "value": 1000
}
}
}
\ No newline at end of file
