242
CHAPTER 9 16-BIT TIMER/COUNTER
9.4.2
16-bit Timer Count Register (TCR)
The timer count register (TCR) is a 16-bit up counter. The counter counts up from the
setting value written in this register.
I
Timer Count Register (TCR)
Figure 9.4-3 "16-bit Timer Count Register (TCR)" shows the bit configuration of the 16-bit timer
count register.
Figure 9.4-3 16-bit Timer Count Register (TCR)
Both in the interval timer and counter function modes, set a counter initial value in this register
while the counter operation is disabled (TMCR: TCS=0). When the counter operation is
enabled (TCS=1), the counter counts up from the value written in this register. While the
counter is stopped (TCS=0), the TCR register maintains its value. If the counter is cleared
(TMCR:TCR=0), the TCR register (counter) becomes 0000
H
.
After the counter is cleared, writing a value in the TCR register sets the counter to the value
written.
You can calculate the value in the TCR register in interval timer mode as follows. Note that the
instruction cycle is the oscillator frequency divided into four cycles (4/Fc).
TCR register value = 2
16
- (Interval time/Instruction cycle)
Set the upper 8 bits as the TCHR register and the lower 8 bits as the TCLR register.
Note:
The value that is set in this register is valid only when the counter is started for the first time.
The counter, if it overflows, counts up from 0000
H
.
A value must be written in this register while the counter is stopped (TMCR: TCS=0).
A value can be read from this register even while the counter is operating.
Always use a word transfer instruction (such as MOVW A, 0019H) to read this register.
bit7
bit6
bit5
bit4
bit3
bit2
bit1
bit0
0 0 7 4
H
Address
00000000
B
Initial value
R
R
R
R
R
R
R
R
R/W
R/W
R/W
R/W
R/W
R/W
R/W
Upper byte (TCHR)
R/W
R
R
R
R
R
R
R
R
00000000
B
0 0 7 5
H
bit7
bit6
bit5
bit4
bit3
bit2
bit1
bit0
Lower byte (TCLR)
Address
Initial value
R/W
R/W
R/W
R/W
R/W
R/W
R/W
R/W
R/W : Read/write enabled
R
: Read only
--> While the counter is stopped
--> While the counter is operating
--> While the counter is stopped
--> While the counter is operating