code that uses Watchdog to reset Mbed every 30seconds. After 30-60mins, the ethernet interface fails to setup() after WatchDog reset.

Dependencies:   mbed

Committer:
eqon
Date:
Thu Jun 07 05:44:29 2012 +0000
Revision:
0:0ce833f21e63

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
eqon 0:0ce833f21e63 1 #include "mbed.h"
eqon 0:0ce833f21e63 2 #include "EthernetNetIf.h"
eqon 0:0ce833f21e63 3 EthernetNetIf eth;
eqon 0:0ce833f21e63 4
eqon 0:0ce833f21e63 5 void dogKick() {
eqon 0:0ce833f21e63 6 LPC_WDT->WDFEED = 0xAA;
eqon 0:0ce833f21e63 7 LPC_WDT->WDFEED = 0x55;
eqon 0:0ce833f21e63 8 printf("dogkick\n");
eqon 0:0ce833f21e63 9 }
eqon 0:0ce833f21e63 10 void setDog(float s =30) {
eqon 0:0ce833f21e63 11 LPC_WDT->WDCLKSEL = 0x1; // Set CLK src to PCLK
eqon 0:0ce833f21e63 12 uint32_t clk = SystemCoreClock / 16; // WD has a fixed /4 prescaler, PCLK default is /4
eqon 0:0ce833f21e63 13 LPC_WDT->WDTC = s * (float)clk;
eqon 0:0ce833f21e63 14 LPC_WDT->WDMOD = 0x3; // Enabled and Reset
eqon 0:0ce833f21e63 15 dogKick();
eqon 0:0ce833f21e63 16 }
eqon 0:0ce833f21e63 17 DigitalOut ethrst(P1_28);// PHY chip on mbed reset
eqon 0:0ce833f21e63 18 DigitalOut led(LED3); //Alive
eqon 0:0ce833f21e63 19 int main() {
eqon 0:0ce833f21e63 20 ethrst=0;//PHY reset
eqon 0:0ce833f21e63 21 wait(1);
eqon 0:0ce833f21e63 22 ethrst=1;
eqon 0:0ce833f21e63 23 wait(1);
eqon 0:0ce833f21e63 24
eqon 0:0ce833f21e63 25 printf("\n\nStartup...\n");
eqon 0:0ce833f21e63 26
eqon 0:0ce833f21e63 27
eqon 0:0ce833f21e63 28 setDog(30);
eqon 0:0ce833f21e63 29 printf("Setting up...\n");
eqon 0:0ce833f21e63 30 EthernetErr ethErr = eth.setup();// i have tested with different timeouts setup(30000) etc
eqon 0:0ce833f21e63 31
eqon 0:0ce833f21e63 32
eqon 0:0ce833f21e63 33 if (ethErr) {
eqon 0:0ce833f21e63 34 printf("Error %d in setup.\n", ethErr);
eqon 0:0ce833f21e63 35 return -1;
eqon 0:0ce833f21e63 36 }
eqon 0:0ce833f21e63 37 printf("Setup OK\n");
eqon 0:0ce833f21e63 38 led=1;
eqon 0:0ce833f21e63 39 return 0;
eqon 0:0ce833f21e63 40
eqon 0:0ce833f21e63 41 }