Section 13 Timer Z
13.4
Operation
13.4.1
Counter Operation
When one of bits STR0 and STR1 in TSTR is set to 1, the TCNT counter for the corresponding
channel begins counting. TCNT can operate as a free-running counter, periodic counter, for
example. Figure 13.7 shows an example of the counter operation setting procedure.
Operation selection
[1] Select the counter
clock with bits
TPSC2 to TPSC0 in
TCR. When an external
clock is selected, select
the external clock edge
with bits CKEG1
[1]
Select counter clock
Periodic counter
and CKEG0 in TCR.
[2] For periodic counter
operation, select the
TCNT clearing
Free-running counter
source with bits
CCLR2 to CCLR0 in
TCR.
[2]
[3]
Select counter clearing source
Select output compare register
[3] Designate the general
register selected in [2]
as an output compare
register by means of
TIOR.
[4] Set the periodic counter
cycle in the general
register selected
Set period
[4]
in [2].
[5]
Start count operation
[5] Set the STR bit in TSTR
to 1 to start the counter
operation.
Figure 13.7 Example of Counter Operation Setting Procedure
Rev. 3.00 Sep. 10, 2007 Page 223 of 528
REJ09B0216-0300