Texas Instruments MSP430x1xx User Manual
Page 139
The Watchdog Timer
9-7
Watchdog Timer
9.1.3.4
Software Example
The following example illustrates the watchdog-reset operation.
; After RESET or power–up, the WDTCTL register and WDTCNT
; are cleared and the initial operating conditions are
; watchdog mode with a time interval of 32 ms.
;
;Constant definitions:
;
WDTCTL
.EQU
0120h ; Address of Watchdog Timer
WDTPW
.EQU
05A00h ; Password
T250MS
.EQU
5
; SSEL, IS0, IS1 set to 250 ms
T05MS
.EQU
2
; SSEL, IS0, IS1 set to 0.5 ms
CNTCL
.EQU
8
; Bit position to reset WDTCNT
TMSEL
.EQU
010h
; Bit position to select timer mode
;
; As long as watchdog mode is selected, watchdog reset has
; to be done periodically through an instruction e.g.:
;
........
........
MOV
#WDTPW+CNTCL,&WDTCTL
;
; To change to timer mode and a time interval of 250 ms,
; the following instruction sequence can be used:
;
MOV
#WDTPW+CNTCL+TMSEL+T250MS,&WDTCTL
; Clear WDTCNT and
; select 250 ms and timer
; mode
........
........
; Note:
The time interval and clear of WDTCNT should be
; modified within one instruction to avoid
; unexpected reset or interrupt
;
; Switching back to watchdog mode and a time interval of
; 0.5 ms is performed by:
;
........
........
MOV
#WDTPW+CNTCL,&WDTCTL
; Reset WDT counter
;
MOV
#WDTPW+T05MS,&WDTCTL
; Select watchdog mode
; and 0.5 ms
........