i have written a code that uses Watchdog to reset Mbed every 30seconds. After 30-60mins, the ethernet interface fails to setup() after WD reset.
If i press reset button, ethernet setup() works. How can that be?
#include "mbed.h"
#include "EthernetNetIf.h"
EthernetNetIf eth;
void dogKick() {
LPC_WDT->WDFEED = 0xAA;
LPC_WDT->WDFEED = 0x55;
printf("dogkick\n");
}
void setDog(float s =30) {
LPC_WDT->WDCLKSEL = 0x1; // Set CLK src to PCLK
uint32_t clk = SystemCoreClock / 16; // WD has a fixed /4 prescaler, PCLK default is /4
LPC_WDT->WDTC = s * (float)clk;
LPC_WDT->WDMOD = 0x3; // Enabled and Reset
dogKick();
}
int main() {
printf("\n\nStartup...\n");
setDog(30);
wait(1);
printf("Setting up...\n");
EthernetErr ethErr = eth.setup(30000);// lets use 30seconds, problem is with default value also
if (ethErr) {
printf("Error %d in setup.\n", ethErr);
return -1;
}
printf("Setup OK\n");
return 0;
}
Hm, and i have also used a reset on PHY chip on mbed like that
DigitalOut ethrst(P1_28);
int main{
ethrst=0;//reset active low
wait(1);
ethrst=1;
wait(1);
//code continues....
}
Seems to work a bit longer.
Ideas?
i have written a code that uses Watchdog to reset Mbed every 30seconds. After 30-60mins, the ethernet interface fails to setup() after WD reset.
If i press reset button, ethernet setup() works. How can that be?
Hm, and i have also used a reset on PHY chip on mbed like that
Seems to work a bit longer.
Ideas?