English
Language : 

HD64F3039F18 Datasheet, PDF (259/710 Pages) Renesas Technology Corp – Renesas 16-Bit Single-Chip Microcomputer H8 Family / H8/300H Series
Section 8 16-Bit Integrated Timer Unit (ITU)
1. Set bits TPSC2 to TPSC0 in TCR to select the counter clock source. If an external clock source
is selected, set bits CKEG1 and CKEG0 in TCR to select the desired edge(s) of the external
clock signal.
2. For periodic counting, set CCLR1 and CCLR0 in TCR to have TCNT cleared at GRA compare
match or GRB compare match.
3. Set TIOR to select the output compare function of GRA or GRB, whichever was selected in
step 2.
4. Write the count period in GRA or GRB, whichever was selected in step 2.
5. Set the STR bit to 1 in TSTR to start the timer counter.
Free-running and periodic counter operation: A reset leaves the counters (TCNTs) in ITU
channels 0 to 4 all set as free-running counters. A free-running counter starts counting up when the
corresponding bit in TSTR is set to 1. When the count overflows from H'FFFF to H'0000, the
overflow flag (OVF) is set to 1 in the timer status register (TSR). If the corresponding OVIE bit is
set to 1 in the timer interrupt enable register, a CPU interrupt is requested. After the overflow, the
counter continues counting up from H'0000. Figure 8.15 illustrates free-running counting.
TCNT value
H'FFFF
H'0000
STR0 to
STR4 bit
OVF
Time
Figure 8.15 Free-Running Counter Operation
When a channel is set to have its counter cleared by compare match, in that channel TCNT
operates as a periodic counter. Select the output compare function of GRA or GRB, set bit CCLR1
or CCLR0 in the timer control register (TCR) to have the counter cleared by compare match, and
set the count period in GRA or GRB. After these settings, the counter starts counting up as a
periodic counter when the corresponding bit is set to 1 in TSTR. When the count matches GRA or
GRB, the IMFA or IMFB flag is set to 1 in TSR and the counter is cleared to H'0000. If the
corresponding IMIEA or IMIEB bit is set to 1 in TIER, a CPU interrupt is requested at this time.
After the compare match, TCNT continues counting up from H'0000. Figure 8.16 illustrates
periodic counting.
Rev.3.00 Mar. 26, 2007 Page 235 of 682
REJ09B0353-0300