6.6
Program Example for Watchdog Timer
Programming examples for the watchdog timer are provided below.
■
Programming Examples of Watchdog Timer
● Processing specification
•
Activate the watchdog timer immediately after the program starts.
•
Clear the watchdog timer whenever the loop of the main program is run.
•
Ensure that the time necessary for running the main loop once, including interrupt handling, is shorter
than the minimum time interval (approximately 335.5 ms: operating at 12.5 MHz) of the watchdog
timer.
● Coding example
WDTC EQU
WDT_CLR EQU 00000101B
VECT
RST_V DW
VECT
;------------------------Main program---------------------------------------------------------------------------------
PROG
INIT
MAIN
;---------------------------------------------------------------------------------------------------------------------
0009H
DSEG
ABS
ORG
0FFFEH
PROG
ENDS
CSEG
MOVW
SP,#0280H
:
Initializing interrupt or other peripheral functions
:
MOV
WDTC,#WDT_CLR
MOV
WDTC,#WDT_CLR
:
User processing (interrupt may occur in this processing.)
:
JMP
MAIN
ENDS
END
CHAPTER 6 WATCHDOG TIMER
; Address of watchdog control register
; [DATA SEGMENT]
; Setting reset vector
; [CODE SEGMENT]
; Initialization routine upon reset
; Setting initial value of stack pointer (for interrupt)
; Activating watchdog timer
; Clearing watchdog timer
; Ensure that the time necessary for running the loop is
shorter than the minimum time interval of the watchdog
timer.
133