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

watchdog not working in 87c520

A strange situation where an internal watchdog reset implementation seems not to work on the 87c520 target while it does work ok when using the Ceibo ICE.

Seems like the reset occurs but unclear where the PC jumps to because the SW does not restart properly but rather stays "stuck" (we know it enters the if (status) passage). With the ICE the program does start ok.

What we do is enable the watchdog timer in the program. In the interrupt handler (ISR 12) depending on some status, we enable the reset itself. All this occurs, but then for the target the program does not go into running normally.

Any ideas?
Thanks,
Baruch



if ( status ) //
{
TA = 0xAA ; //Accessing timed access in order to start the watchdog timer
TA = 0x55 ; //
EWT = 1 ; // Enable WatchDog timer reset

TA = 0xAA; //Accessing timed access in order to start the watchdog timer
TA = 0x55; //
WDIF = 0 ; // watch dog flag clear
}

else
{
TA = 0xAA; //Accessing timed access in order to start the watchdog timer
TA = 0x55; //
WDIF = 0 ; // watch dog flag clear

TA = 0xAA ; //Accessing timed access in order to start the watchdog timer
TA = 0x55 ; //
RWT = 1 ; // Restart Watchdog timer

}

Parents
  • void main ()
    {
    // disable WDT hardware reset.
    // if wdt ever fires,
    // the initialization
    // and the prom checksum could not
    // complete before wdt fired again,
    // staying there forever, so disable
    // wdt till checksum over.

    // disable WDT hardware reset
    EA = 0; // disable all interrupts
    TA = 0xaa;
    TA = 0x55;
    WDCON = WDCON & ~EWT_;


    other initialization here

    then just before main loop

    // initialize WATCH Dog Timer
    // set WDT for 56.889MS...18.432mhz cry
    // see page 116 in dallasbook
    CKCON |= WD0_;
    CKCON &= ~WD1_;

    // Enable hardware reset
    // if Watch Dog Timer expires
    EA = 0; // disable interrupts
    TA = 0xaa;
    TA = 0x55;
    WDCON = WDCON | EWT_; // Enable WDT

    EA = 1; // enable interrupts

    // MAIN LOOP
    do
    {

    //Watch Dog Timer Reset
    EA = 0; // disable interrupts !!
    // if any interrupt occurs during
    // the following 3 instructions
    // the wdt will not be reset
    // so disable interrupts
    TA = 0xaa;
    TA = 0x55;
    WDCON = WDCON | RWT_; //reset wdt
    EA = 1; // enable all interrupts!!

    other main loop things

    }while(1);

    } // end of main

Reply
  • void main ()
    {
    // disable WDT hardware reset.
    // if wdt ever fires,
    // the initialization
    // and the prom checksum could not
    // complete before wdt fired again,
    // staying there forever, so disable
    // wdt till checksum over.

    // disable WDT hardware reset
    EA = 0; // disable all interrupts
    TA = 0xaa;
    TA = 0x55;
    WDCON = WDCON & ~EWT_;


    other initialization here

    then just before main loop

    // initialize WATCH Dog Timer
    // set WDT for 56.889MS...18.432mhz cry
    // see page 116 in dallasbook
    CKCON |= WD0_;
    CKCON &= ~WD1_;

    // Enable hardware reset
    // if Watch Dog Timer expires
    EA = 0; // disable interrupts
    TA = 0xaa;
    TA = 0x55;
    WDCON = WDCON | EWT_; // Enable WDT

    EA = 1; // enable interrupts

    // MAIN LOOP
    do
    {

    //Watch Dog Timer Reset
    EA = 0; // disable interrupts !!
    // if any interrupt occurs during
    // the following 3 instructions
    // the wdt will not be reset
    // so disable interrupts
    TA = 0xaa;
    TA = 0x55;
    WDCON = WDCON | RWT_; //reset wdt
    EA = 1; // enable all interrupts!!

    other main loop things

    }while(1);

    } // end of main

Children
No data