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

0