Hitachi H8/3152 Hardware Manual page 72

Single-chip microcomputer h8/3150 series
Table of Contents

Advertisement

To reload the initial value to TCNT using the TCWA function, an instruction that writes to TCNT
is used. Specify, in TCWA, the address where the instruction that writes to TCNT is stored, before
initializing TCSR and TCNT in the WDT initializing routine. At the same time, set the WAD bit
in TCWA to 0. When the write instruction stored in the address specified in TCWA is executed,
the value initially set to TCNT in the WDT initializing routine is reloaded to TCNT. With this
write instruction, any value can be specified as a write data but the initial value is written to TCNT
regardless of the specified write data. The write instruction for reloading must be stored in the
ROM area pointed to by the specified address; if it is stored outside the specified ROM area,
TCNT will not be reloaded. Figure 5.8 shows the memory contents when TCNT reloading is
specified.
--- Example of program in TCNT reloading ---
CPUinit:
MOV.B
#H'00, R0L
MOV.B
R0L, @SYSCR
WDTinit:
MOV.B
#H'10, R0L
MOV.B
R0L, @TCWA
MOV.B
#H'2F, R0L
MOV.B
R0L, @TCSR
MOV.B
#H'FF, R0L
MOV.B
R0L, @TCNT
---------------
.org
H'1000
TCNTreload:
MOV.B
R0L, @TCNT
--- End ---
H'1000
H'2000
68
; CPU speed = CLK/2
; WAD = 0, enable address = H'1000–H'1FF7
; CS = CLK/256
; UDF interval
; TCNT reload
MOV.B
R0L, @TCNT
MOV.B
R0L, @TCNT
Figure 5.8 Memory Contents for Reloading TCNT
TCNT reloading enabled
TCNT reloading disabled

Advertisement

Table of Contents
loading

Table of Contents