
229
8.3 Structure of 8/16-bit Timer/Counter
8.3.3
Timer 1 Data Register (T1DR)
The Timer 1 data register (T1DR) 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 1 interval time (interval timer
function) or counter value (counter function), and reads out the counter value. In 16-bit
mode, it sets the 8 LSBs of the 16-bit timer interval (interval timer function) or counter
value (counter function), and reads out the counter value.
s Timer 1 Data Register (T1DR)
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-6 "Timer 1 Data Register (T1DR)" shows the bit structure of the Timer 1 data
register.
Figure 8.3-6 Timer 1 Data Register (T1DR)
r 8-bit mode (Timer 1)
The value in this register is compared with the count in the timer 1 counter. For the interval timer
function it sets the interval time, and for the counter function, it sets the count to be detected.
When count operation enabled (T1CR: T1STR = 0 --> 1, T1STP = 0), the value in the T1DR
register is loaded into the comparison data latch, and the counter starts counting up.
When the counter counts up to where it matches the value in the comparison data latch, the
value in the T1DR register is re-loaded into the comparison data latch, and the counter is
cleared and continues to count.
Since the comparison data latch is reloaded when a match is detected, if a new value is loaded
into the T1DR 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 T1DR 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.)
T1DR register value = interval time/(count clock cycle × instruction cycle) -1
Address
Bit 7
Bit 6
Bit 5
Bit 4
Bit 3
Bit 2
Bit 1
Bit 0
Initial value
001BH
XXXXXXXXa
R/W
R/W: Readable and writable