
170
CHAPTER 8 8/16-BIT CAPTURE TIMERS/COUNTERS
falling).
The comparator compares the counter value with the comparator data latch value.
When these values match, the counter is cleared and the data register value is set in (loaded to)
the comparator data latch.
In the 8-bit mode, counter circuits 0 and 1 operate independently as timer 0 and timer 1,
respectively. In the 16-bit mode, counter circuits 0 and 1 operate as the 16-bit counter in which
counter circuit 0 is concatenated as lower 8 bits and counter circuit 1 is concatenated as higher
8 bits.
r Square wave output control circuit
When the comparator detects that the counter value matches the comparator data latch value in
the 8- or 16-bit mode, an interrupt request is generated. In this case, if square wave output is
allowed, the corresponding output control circuit inverts the output of the square wave output
pin.
r Timer 0/1 data registers (TDR0, TDR1)
TDR0 and TDR1 are used to set the data to be compared with each 8-bit counter value at write.
r Timer 0/1 control registers (TCR0, TCR1)
TCR0 and TCR1 are used to select functions, allow and prohibit operations, control interrupts,
and check interrupt states.
r 8/16-bit capture timer/counter interrupt
IRQ3: If the interrupt request output is allowed when the counter value equals the value set in
the data register in the interval timer or counter function, an IRQ3 interrupt request is generated.
(In timer 0 for the 8-bit mode or in the 16-bit mode, the interrupt request output is allowed when
TCR0: T0IEN=1. In timer 1 for the 8-bit mode, the interrupt request output is allowed when
TCR1: T1IEN =1.)
r 8/16-bit capture counter interrupt
IRQ4: If the interrupt request output is allowed each time a capture input edge is detected, an
IRQ4 interrupt request is generated. (In timer 0 for the 8-bit mode or in the 16-bit mode, the
interrupt request output is allowed when TCCR: TCEN=1.)
r Capture data registers (TCPL, TCPH)
TCPL and TCPH store the number of events detected in the capture mode.
When capture data is read in the timer mode, the counter value is also read.
r Timer output control register (TCR2)
TCR2 is used to allow and prohibit square wave output and select timer 0 output/timer 1 output.