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.
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; // Set CLK src to PCLK 00009 uint32_t clk = SystemCoreClock / 16; // WD has a fixed /4 prescaler, PCLK default is /4 00010 LPC_WDT->WDTC = s * (float)clk; 00011 LPC_WDT->WDMOD = 0x3; // Enabled and Reset 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 }
Generated on Fri Jul 15 2022 13:44:28 by
1.7.2