CHAPTER 8 TIMER 0
178
(1) Timer register 0 (TM0)
TM0 is a timer register that counts up the count clock specified by the prescaler mode register (PRM).
Counting of this timer register is enabled or disabled by the timer mode control register (TMC).
The timer register can be only read by using a 16-bit manipulation instruction. When RESET is input, TM0 is cleared
to 0000H and stops counting.
(2) Capture/compare registers (CC00 through CC03)
CC0n (n = 0 to 3) is a 16-bit register that can be used as a compare register to detect match between its value and
the count value of TM0 or as a capture register to capture the count value of TM0. Whether CC0n is used as a
compare register or capture register is specified by the timer unit mode register 0 (TUM0).
This register can be read or written by using a 16-bit manipulation instruction.
When RESET is input, the value of this register is undefined.
(a) As compare register
When used as a compare register, CC0n functions as a 16-bit register that holds the value determining the cycle
of the interval timer operation.
When the contents of CC0n matches with the contents of TM0, an interrupt request (INTCC0n: n = 0 to 3) and
a timer output control signal are generated.
When the CE0 bit of the timer mode control register (TMC) is 0 and timer 0 is stopped, the capture operation
is not performed.
(b) As capture register
When used as a capture register, CC0n functions as a 16-bit register that captures the contents of TM0 in
synchronization with the valid edge (capture trigger) input from an external interrupt input pin (INTPn: n = 0
to 3).
The contents of CC0n are retained until the next capture trigger is generated.
(3) Edge detection circuit
The edge detection circuit detects the valid edge of an external input.
It detects the valid edge of the INTP0 through INTP3 pin inputs, and generates an external interrupt request (INTP0
to INTP3) and capture trigger. The valid edge is specified by the external interrupt mode registers (INTM0 and
INTM1) (for the details of INTM0 and INTM1, refer to
Figures 15-1
and
15-2
).
(4) Output control circuit
When the contents of CC0n (n = 0 to 3) and the contents of TM0 match, the timer output can be inverted. A square
wave can be output from a timer output pin (TO00 to TO03) if so specified by the timer output control register 0
(TOC0). The TO00 and TO02 pins can also output a set and reset signals if so specified by the timer unit mode
register 0 (TUM0).
The timer output can be enabled or disabled by TOC0. When the timer output is disabled, a fixed level is output
to the TO0n (n = 0 to 3) pin (the output level is fixed by TOC0).
(5) Prescaler
The prescaler generates a count clock by dividing the internal system clock. The clock generated by the prescaler
is selected by the selector, and TM0 performs the count operation by using this clock as a count clock.
(6) Selector
The selector selects one of the five signals generated by dividing the internal system clock as the count clock of
TM0.