Generate sine waves with 2 mbeds synchronised. Configurable amplitude and phase. Built for 50 Hz mains simulations.

Dependencies:   MODDMA mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers watchdog.h Source File

watchdog.h

00001 // Simon's Watchdog code from
00002 // http://mbed.org/forum/mbed/topic/508/
00003 class Watchdog {
00004 public:
00005 // Load timeout value in watchdog timer and enable
00006     void kick(float s) {
00007         LPC_WDT->WDCLKSEL = 0x1;                // Set CLK src to PCLK
00008         uint32_t clk = SystemCoreClock / 16;    // WD has a fixed /4 prescaler, PCLK default is /4
00009         LPC_WDT->WDTC = s * (float)clk;
00010         LPC_WDT->WDMOD = 0x3;                   // Enabled and Reset
00011         kick();
00012     }
00013 // "kick" or "feed" the dog - reset the watchdog timer
00014 // by writing this required bit pattern
00015     void kick() {
00016         LPC_WDT->WDFEED = 0xAA;
00017         LPC_WDT->WDFEED = 0x55;
00018     }
00019 };