WatchdogExample
Published 17 Feb 2010, by
Simon Ford
example,
watchdog
« Back to documentation index
Show/hide line numbers
main.cpp Source File
main.cpp
00001 #include "mbed.h"
00002
00003 DigitalOut led(LED1);
00004
00005 class Watchdog {
00006 public:
00007 void kick(float s) {
00008 LPC_WDT->WDCLKSEL = 0x1;
00009 uint32_t clk = SystemCoreClock / 16;
00010 LPC_WDT->WDTC = s * (float)clk;
00011 LPC_WDT->WDMOD = 0x3;
00012 kick();
00013 }
00014
00015 void kick() {
00016 LPC_WDT->WDFEED = 0xAA;
00017 LPC_WDT->WDFEED = 0x55;
00018 }
00019 };
00020
00021 Watchdog w;
00022
00023 int main() {
00024 printf("Hello World!\n");
00025 w.kick(2.5);
00026
00027 int hang = 0;
00028 while(1) {
00029 printf("loop...\n");
00030 wait(0.1);
00031
00032 if(hang == 10) {
00033 while(1);
00034 }
00035
00036 w.kick();
00037 hang++;
00038 }
00039 }