186
CHAPTER 7 8-BIT PWM TIMER
7.1
Overview of 8-bit PWM Timer
The 8-bit PWM timer can be selected to function as either an interval timer or PWM
timer with 8-bit resolution. The interval timer function count-up in sync with either the
8/16-bit timer/counter (timer 1, timer 2) or one of three internal count clocks.
Therefore, an 8-bit interval timer time can be set and the output can be used to
generate variable frequency square waves. Also, the 8-bit PWM timer can be used as a
D/A converter by connecting the PWM output to low pass filter.
There are two 8-bit PWM timer "channels", that perform the same function: 8-Bit PWM
Timer 1 and 8-Bit PWM Timer 2.
s Interval Timer Function (Square Wave Output Function)
The interval timer function generates repeated interrupts at variable time intervals.
Also, as the 8-bit PWM timer can invert the output level of the pin (PWM1, PWM2) each time an
interrupt is generated, the 8-bit PWM timer can output a variable frequency square waves.
Each 8-bit PWM timer (1 and 2) can operate independently of the other.
The interval timer can operate with a cycle among 1 and 28 times the count clock cycle.
The count clock can be selected from four different clocks.
Table 7.1-1 "Interval Time and Square Wave Output Range" lists the range for the interval time
and square wave output.
tinst: Instruction cycle (affected by clock mode, etc.)
text: 8/16-bit timer/counter Timer 1 external clock period (8-bit PWM Timer 1 only)
8-bit timer output cycle: 8/16-bit timer/counter 8-bit timer output (Timer 1, Timer 2)
Note:
Calculation example for the interval time and square wave frequency
In this example, the main clock source oscillation (FCH) is 4.2 MHz, the PWM compare
register (COMR) value is set to "DDH (221)" and the count clock cycle is set to 1 tinst. In this
Table 7.1-1 Interval Time and Square Wave Output Range
Count clock cycle
Interval time
Square wave output (Hz)
1
Internal count
clock
1 tinst
1 tinst to 2
8 t
inst
1/(2 tinst) to 1/(2
9 t
inst)
216 tinst
24 tinst to 2
12 t
inst
1/(25 tinst) to 1/(2
13 t
inst)
364 tinst
26 tinst to 2
14 t
inst
1/(27 tinst to 1/(2
15 t
inst)
48-bit timer
output cycle
22 tinst to 2
10 t
inst
22 tinst to 2
18 t
inst
1/(23 tinst) to 1/(2
19 t
inst)
26 tinst to 2
14 t
inst
26 tinst to 2
22 t
inst
1/(27tinst) to 1/(2
23 t
inst)
210 tinst to 2
18 t
inst
210 tinst to 2
26 t
inst
1/(211 tinst) to 1/(2
27 t
inst)
1text to 2
8 t
ext
1 text to 2
16 t
ext
1/(2 text) to 1/(2
9 t
ext)