
166
CHAPTER 8 8/16-BIT CAPTURE TIMERS/COUNTERS
Note:
Example of calculating interval time and square wave frequency
If the oscillation (FCH) is set to 10 MHz, the timer 0 data register (TDR0) value is set to
DDH(221), and the count clock cycle is set to 2tINST 8-bit mode operation, the interval time of
timer 0 and the square wave frequency output from the TO pin when the interval timer
function is operated continuously without modifying the TDR0 register value are calculated
from the following expressions:
However, the values calculated from these expressions are valid when the highest speed
clock of the normal mode (CS1, CS0 = 11B, 1 instruction cycle = 4/FCH) is selected
according to the system click control register (SYCC).
s Counter Function
The counter function counts the falling edges of the external clocks input to the P33/EC external
pin. The 8/16-bit capture timer/counter can operate independently because the EC pin acts as
an external clock input pin. Only timer 0 can select the external clock. The counter function
operates using timer 0 with the 8-bit mode or with the 16-bit mode.
The counter function counts the number of edges of the external clocks selected by the
count clock selection bit (CINV) of the timer 0 control register (TCR0). When the number of
Table 8.1-3 Interval Time and Square Wave Output Range in 16-bit Mode
Count clock cycle
Interval time
Square wave output range (Hz)
Internal count clock
2tINST
2tINST to 2
17t
INST
1/ (22tINST) to 1/ (2
18t
INST)
4tINST
22tINST to 2
18t
INST
1/ (23tINST) to 1/ (2
19t
INST)
16tINST
24tINST to 2
20t
INST
1/ (25tINST) to 1/ (2
21t
INST)
64tINST
26tINST to 2
22t
INST
1/ (27tINST) to 1/ (2
23t
INST)
128tINST
27tINST to 2
23t
INST
1/ (28tINST) to 1/ (2
24t
INST)
256tINST
28tINST to 2
24t
INST
1/ (29tINST) to 1/ (2
25t
INST)
512tINST
29tINST to 2
25t
INST
1/ (210tINST) to 1/ (2
26t
INST)
External clock
1tEXT
1tEXT to 2
16t
EXT
1/ (2tEXT) to 1/ (2
17t
EXT)
tINST: Instruction cycle (this cycle is affected by the clock mode, etc.)
tEXT: External clock cycle (1tEXT greater than or equal to 4tINST)
Interval time = (2 x 4/FCH) x (TDR0#1 register value + 1)
= (8/10 MHz) x (221 + 1)
177.6 S
Output frequency = FCH/(2 x 8 x (TDR0#1 register value + 1))
= 10 MHz/(16 x (221 + 1))
2.82 kHz