231
8.3 Structure of 8/16-bit Timer/Counter
8.3.4
Timer 2 Data Register (T1DR)
The Timer 2 data register (T2DR) is used to set all or part of the interval time or counter
value, and to read out all or part of the counter value, depending on the mode and
function being used. In 8-bit mode, it sets the Timer 2 interval time (interval timer
function) or counter value (counter function), and reads out the counter value. In 16-
bit mode, it sets the 8 MSBs of the 16-bit timer interval (interval timer function) or
counter value (counter function), and reads out the counter value.
s Timer 2 Data Register (T2DR)
The value set into this register is compared with the counter value (count). If you read the
register, you get the current counter value. The register setting cannot be read out.
Figure 8.3-7 "Timer 2 Data Register (T2DR)" shows the bit structure of the Timer 2 data
register.
Figure 8.3-7 Timer 2 Data Register (T2DR)
r 8-bit mode (Timer 2)
The value in this register is compared with the count in the timer 2 counter. For the interval timer
function, it sets the interval time, and for the counter function, it sets the count to be detected.
The value in the T2DR register is reloaded into the comparison data latch when counter
operation starts, and when a match is detected.
If a new value is loaded into the T2DR register while the counter is counting, the new value will
not take effect until the next count cycle (after a match is detected in the current cycle).
Note:
The T2DR setting for interval timer operation can be calculated using the following formula.
(The instruction cycle time is affected by the clock mode, and the speed-shift selection.)
T2DR register value = interval time/(count clock cycle × instruction cycle time) -1
r 16-bit mode
The value in this register is compared with upper 8 bits (MSBs) of the 16-bit timer. In the interval
timer function, this sets the upper 8 bits of the interval time setting, and in the counter function,
the upper 8 bits of the count to be detected. The contents of the T2DR register are loaded into
the upper 8 bits of the comparison data latch when the counter first starts operating and when a
match is detected in the 16-bit count. Therefore, if a new value is loaded into the T2DR register
while the 16-bit counter is counting, the new value will not take effect until after the next match
is detected. In the 16 bit mode, the operation of the counter is controlled by the Timer 1 control
register (T1CR).
Address
Bit 7
Bit 6
Bit 5
Bit 4
Bit 3
Bit 2
Bit 1
Bit 0
Initial value
001AH
XXXXXXXXB
R/W
R/W: Readable and writable