Hi, I'm trying to setup watchdog but it deosn't run Any hints?
#include <Reg935.h> void InizWatchDog(void); void WatchDogFeed(void); void ResetSW(void); void StartWatchdog(void); void main() { P2M1 = 0x01; P2M2 = 0x01; InizWatchDog(); StartWatchdog(); while (1) { P2 = 0x02; WatchDogFeed(); ResetSW(); } } // void InizWatchDog(void) { bit eacopy; WDL = 0xFD; //set wd to maxcount eacopy = EA; EA = 0; WDCON = 0xE5; WFEED1 = 0xA5; WFEED2 = 0x5A; EA = eacopy; } void WatchDogFeed(void) { bit eacopy; // disable interrupts eacopy = EA; EA = 0; // feed the watchdog WFEED1 = 0xA5; WFEED2 = 0x5A; // restore interrupts EA = eacopy; } void StartWatchdog(void) { bit eacopy; // disable interrupts eacopy = EA; EA = 0; // start the watchdog WDCON |= 0x04; // feed the watchdog WFEED1 = 0xA5; WFEED2 = 0x5A; // restore interrupts EA = eacopy; } void ResetSW() { while(1) { P2 = 0x01; } }
since it seems that you are using the LPC935 (you do not say), have you tried the code generated by CodeArchitect, free from http://www.esacademy.com Erik
Hi all, the inner loop, brought by "ResetSW()" it's only there because I'm tryin to put in stall conditions the micro waiting for watchdog to reset all and restore normal func. Calling an infinite loop is a safe way to reset the micro, if watchdog wants to help you... Yes, i'm using LPC935 and the above code is already generated by Code Architect.
but it deosn't run How do you determine that fact? Erik
Hi Erik, a breakpoint near port setting tell me that the micro does not reboot...
Setting the breakpoint --- in what? Emulator, MON51, ISD51, simulator?