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
  • Hi,
    first of all - do you read Errata about this MCU? There are alot of problems include bad execution of program from 0x0000 after watchdog reset.
    Seems, the problem is that your software executes any MOVX instruction due watchdog reset as it said in Errata. Really, EWT does not implement momentarely reset but just enables it after about 512 cycles. So your software goes into watchdog ISR then enables reset and comes back to main execution where (probably) there is a MOVX instruction(s). All you need to do is modify ISR something like:

    if ( status ) //
    {
    EA=0;         // disable all interrupts
    
    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
    
    // stop rest program execution
    dead_loop:
    goto dead_loop;
    }
    
    This way stops execution of next commands and so watchdog will restart MCU due JMP command that is correct.

    Good days!

Reply Children
More questions in this forum