
How to use the
Watchdog Timer of the TriCore
14 of 17
AP3219 Rel.02
6.3
The following procedure is nearly the same as the procedure used in chapter Password
Access. The great difference is the variable hand over to the procedure. If these variable
does not match with the password already stored in WDTCON0.WDTPW a Watchdog
Timer Access Error (WDTSR.WDTAE) will occur.
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
Password Access using the Extended Security Thoughts
//Password Access to unlock WDTCON0 using the Extended Security Thoughts
//include this in your project
void WDT_Pass_Secure(unsigned char oldpass)
{
#define
WDTCON0 *((volatile unsigned int*) 0xF0000020)
#define
WDTCON1 *((volatile unsigned int*) 0xF0000024)
unsigned int passwd;
passwd = WDTCON0;
//load value from WDTCON0 in variable
passwd = passwd & 0xffff00ff;
passwd = passwd | (oldpass << 8);
//value from variable included
passwd = passwd | 0x0f0;
//sets bit 7:4 to 1
passwd =
WDTCON1 & 0x00c)
//bit 2:3 loaded from WDTCON1
| (passwd & 0xfffffff3);
//and bit 2:3 cleared from WDTCON0
passwd = (passwd ^ 0x00000002);
//invert bit 1
WDTCON0 = passwd;
//write password to register WDTCON0
//bits from the WDTPW cleared
}
The following procedure call will unlock the WDTCON0 register if the value of the variable
Oldpassword does match with the password already stored in WDTCON0.WDTPW. If not,
an error will occur and the WDT will enter in the Reset Pre-warning Mode.
//Procedure call
WDT_Pass_Secure(Oldpassword);