220
CHAPTER 8 8/16-BIT TIMER/COUNTER
r Count clock selectors 1, 2
This circuit selects an input clock. In the 8-bit timer 1 and 16 bit modes, count clock selector 1
selects one of four clocks: three internal clocks, and an external clock. In the 8-bit mode, count
Clock Selector 2 selects one of three internal clocks only.
r Counter circuit 1, 2
Counter circuit 1 and counter circuit 2 are each made up of an 8-bit counter, a comparator, a
comparison data latch, and a data register (T1DR or T2DR).
In each counter circuit, the 8-bit counter is an up-counter clocked by the selected count clock.
The comparator compares the count in the counter with the value in the comparison data latch.
When it detects a match, it clears the counter, and loads the contents of the data register into
the comparison data latch.
In the 8 bit-mode, the two counter circuits operate independently as timer 1 and timer 2. In the
16-bit mode, the two circuits are connected in series to form a single 16-bit counter with counter
circuit 1 forming the low (8 LSBs) end of the counter, and counter circuit 2 at the high (8 MSBs)
end.
r Square wave output control circuit
An interrupt request is generated when the comparator detects a match in the 8-bit timer 1
mode or the 16-bit mode. At this time, if the square wave output is enabled, the output control
circuit inverts the level output at the TO pin.
The circuit can also initialize the output level to have the output square wave start out in a
specific state ("H" or "L").
r T1DR and T2DR registers
The value to be compared with the count in the counter is set by writing the desired value into
these registers. They can be read to determine the current counter values.
r T1CR and T2CR registers
The T1CR and T2CR registers are used to select the function, to enable or disable operation,
control interrupts, and check the timer/counter status.