AnsweredAssumed Answered

Implementing watchdog timer in ADuC7026

Question asked by pssijo on May 13, 2013
Latest reply on May 13, 2013 by AudeR

Hi,

I want to implement watch dog timer in my applications.

Application looks somewhat like this :

void main()

{

T3LD = 0xFFFF;   

T3CON = 0xE2;

.....

//(based on some conditions )

while(1)

{

  ....

   somefn();

  ....

}

 

  while(1)

{

  ....

   somefn();

  ....

}

 

}

 

void My_IRQ_function()

{

if ((IRQSTA & RTOS_TIMER_BIT) != 0)

{

  ......

}

 

if ((IRQSTA & WATCHDOG_TIMER_BIT) != 0)    // Timer3 IRQ?

{                                        // Watchdog interrupt allows saving...

                                        //... data before reset if necessary

  RSTSTA = 0x4;                    // Software reset

}

}

 

Since multiple loops are there and sometimes each loop may work for longtime based on some conditions. Do I need to write T3CLRI every time in each loop to prevent WDT from expiring? How to decide the timeout period( or just based on the maximum time required to execute the loop?).

Is there anyway to save the present state (means some register values which I don't want to change while resetting)  of processor just before resetting?

And also I want to know which is the best option for resetting processor from illegal state

- watchdog expiration or software reset(RSTSTA) and why?

Outcomes