
How to use the
Watchdog Timer of the TriCore
8 of 17
AP3219 Rel.02
The following program in C-Code is an example how to change the register WDTCON0. It
can be included as a procedure in the mainfunction:
//Modify Access to WDTCON0 include this in your project
void WDT_Modify(unsigned long modify, unsigned long mask)
{
#define
WDTCON0 *((volatile unsigned int*) 0xF0000020)
unsigned int newvalue;
//by the mask selected bits will be changed by the variable modify
newvalue = WDTCON0 & (~mask));
newvalue = newvalue | (modify & mask);
newvalue = ((0xf2 | newvalue) & (0xfffffff3));
//bit 1 and 7:4 are
//written to 1’s and bit 3:2 written to 0’s
WDTCON0 = newvalue;
//write newvalue to WDTCON0
}
Now you can call the above mentioned procedure with the following instructions:
Mask = 0x0000000f;
Modify = 0x0000000f;
//new value for WDTCON0, ENDINIT will be set to
//bits that will be changed set to 1
WDT_Modify(Modify, Mask);
//Procedure call
Note:
The values of the variables “Mask” and “Modify” can be changed. This is only an
example and is described in the section entitled “How to change the WDTCON0”.
3.3
There are two classes of Watchdog Timer Errors:
Watchdog Access Error:
an incorrect access to WDTCON0 was attempted
Watchdog Timer Overflow Error:
the WDT counter overflowed
The Watchdog Access Error Status Flag, WDTSR.WDTAE, is set in case of an access
error. A Watchdog Access Error is generated when:
An illegal password is supplied during password access to register WDTCON0
Improper guard bits are supplied during a modifying access to WDTCON0
The Watchdog Overflow Error Status Flag, WDTSR.WDTOE, is set if an overflow error
occurs. A Watchdog Timer Overflow Error is generated if the WDT counter overflows. In all
error cases, the Watchdog Timer:
Generates an NMI trap request
Enters the Reset Pre-warning Mode
Sets the Watchdog Reset Pre-warning Flag, WDTSR.WDTPR and Watchdog Time-out
Period Indication Flag, WDTSR.WDTTO
Note:
When reset is caused by the WDT, the two error flags, WDTSR.WDTOE and
WDTSR.WDTAE, are not cleared. This allows the WDT to detect the Double
Watchdog Error condition. Any other reset cause will clear these error flags. They
are also cleared when WDTCON0.ENDINIT is set to 1.
Watchdog Error Conditions