216
CHAPTER 8 8/16-BIT TIMER/COUNTER
8.1
Overview of 8/16 -bit Timer/Counter
The 8/16-bit timer/counter is made up of two 8-bit timers (Timer 1 and Timer 2) that can
be used separately (8-bit mode) or connected in cascade to form one counter (16-bit
mode).
Timer 1 can be selected to function as either an interval timer or a counter. The interval
timer function counts up in sync with one of three interval count clocks. The counter
function counts up by a clock input to the external pin.The output can be used to
generate variable frequency square wave output.
Timer 2 functions as an interval timer clocked by one of three internal count clocks. In
the 16 bit mode, it is connected in series with Timer 1.
s Interval Timer Function
The interval timer function generates repeated interrupts at variable intervals. Also, as the 8/16-
bit timer/counter can invert the output level of the pin (TO pin) each time an interval time is
generated, the 8/16-bit timer/counter can output variable frequency square waves (Timer 1 in 8
bit mode, or 16 bit mode).
In 8-bit mode, Timer 1 and Timer 2 operate as two independent interval timers, each of
which can count time intervals ranging from the clock period (the time of one clock cycle) to
28 times the clock period.
In 16-bit mode, the two counters form a single 16-bit timer, with Timer 1 containing the LSBs
and Timer 2 the MSBs. The interval timer can operate with a cycle among 1 and 216 times
the internal count clock cycle.
The count clock can be selected from three different internal clocks. (An external clock can
be selected for Timer 1, but it will then function as a counter).
Timer 1 and Timer 2 outputs can be used as the count clocks for 8-Bit PWM Timer 1 and 8-
Bit PWM Timer 2, respectively.
The Timer 1 output can be used as the clock for the A/D converter in continuous operation
mode.
Table 8.1-1 "Timer 1 Interval Times and Square Wave Frequencies in 8-bit Mode" to 8.1-3
"Interval Times and Square Wave Frequencies 16-bit Mode" list the interval time and square
wave output ranges for the various modes.
Table 8.1-1 Timer 1 Interval Times and Square Wave Frequencies in 8-bit Mode
Count clock cycle
Interval time
Square wave output range (Hz)
Internal count clock
2 tinst
2 tinst to 2
9 t
inst
1/(22 tinst) to 1/(2
10 t
inst)
32 tinst
25 tinst to 2
13 t
inst
1/(26 tinst) to 1/(2
14 t
inst)
512 tinst
29 tinst to 2
17 t
inst
1/(210 tinst) to 1/(2
18 t
inst)
External clock
1 text
1 text to 2
8 t
ext
1/(2 text) to 1/(2
9 t
ext)