Watchdog

Post
BulleTracker
Starting Member
2011/03/04 15:13:48
Hello all,
I need help since i can not get the watchdog timer to work on a PIC24HJ256GP610 and 610A
 
here is my code to understand, on explorer 16 board :
 -> normal running before watchdog time out -> Led 0 is blinking to say that RCONbits.WDTO is 0
 -> After reset, -> Led 1 should blink to say that RCONbits.WDTO is 1 ! but it never happens !!!! ????
 
Any idea ?
here is my code :
 
_FOSCSEL( FNOSC_FRC );  // Fast RC oscillator
_FOSC( FCKSM_CSECMD & OSCIOFNC_OFF  & POSCMD_XT );
_FWDT( FWDTEN_OFF & WINDIS_OFF & WDTPRE_PR32 & WDTPOST_PS1024 );          // Watchdog Timer
_FICD( JTAGEN_OFF & ICS_PGD1 );
 
 
Led0TrisPin = 0;        // LedPin is an Output
Led1TrisPin = 0;        // LedPin is an Output
 
RCONbits.SWDTEN = 1;          // Enable WatchDog Timer !
 
if ( RCONbits.WDTO )
 {         
 RCONbits.SWDTEN = 0;
    while(1)            // so blink Led for ever !
  {
  LedToggle(1);
  sleep1ms(10); 
  }
 }
else
 {
 while (1)             // Test function of Watchdog
  {
  LedToggle(0);
  sleep1ms(10);           // Watchdog should not Time Out
  }
 }
}
BulleTracker
Starting Member
Re:Watchdog 2011/03/04 18:53:34
i found it myself !!! sorry for that !

This line was missing :

RCONbits.WDTO = 0

This gives now, and it works :


_FOSCSEL( FNOSC_FRC );  // Fast RC oscillator
_FOSC( FCKSM_CSECMD & OSCIOFNC_OFF  & POSCMD_XT );
_FWDT( FWDTEN_OFF & WINDIS_OFF & WDTPRE_PR32 & WDTPOST_PS1024 );          // Watchdog Timer
_FICD( JTAGEN_OFF & ICS_PGD1 );
 
 
Led0TrisPin = 0;        // LedPin is an Output
Led1TrisPin = 0;        // LedPin is an Output
 
RCONbits.SWDTEN = 1;          // Enable WatchDog Timer !
 
if ( RCONbits.WDTO )
 {          
 RCONbits.WDTO = 0
 RCONbits.SWDTEN = 0;
    while(1)            // so blink Led for ever !
  {
  LedToggle(1);
  sleep1ms(10); 
  }
 }
else
 {
 while (1)             // Test function of Watchdog
  {
  LedToggle(0);
  sleep1ms(10);           // Watchdog should not Time Out
  }
 }
}