This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Using watchdog?

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;

	}
}


Thanks

Parents
  • 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.

Reply
  • 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.

Children