158
2467S–AVR–07/09
ATmega128
shows the COM21:0 bit functionality when the WGM21:0 bits are set to fast PWM
mode.
Note:
1. A special case occurs when OCR2 equals TOP and COM21 is set. In this case, the compare
match is ignored, but the set or clear is done at BOTTOM. See
for more details.
shows the COM21:0 bit functionality when the WGM21:0 bits are set to phase correct
PWM mode.
Note:
1. A special case occurs when OCR2 equals TOP and COM21 is set. In this case, the compare
match is ignored, but the set or clear is done at TOP. See
“Phase Correct PWM Mode” on page
for more details.
• Bit 2:0 – CS22:0: Clock Select
The three clock select bits select the clock source to be used by the Timer/Counter.
Table 65.
Compare Output Mode, Non-PWM Mode
COM21
COM20
Description
0
0
Normal port operation, OC2 disconnected.
0
1
Toggle OC2 on compare match
1
0
Clear OC2 on compare match
1
1
Set OC2 on compare match
Table 66.
Compare Output Mode, Fast PWM Mode
COM21
COM20
Description
0
0
Normal port operation, OC2 disconnected.
0
1
Reserved
1
0
Clear OC2 on compare match, set OC2 at BOTTOM,
(non-inverting mode)
1
1
Set OC2 on compare match, clear OC2 at BOTTOM,
(inverting mode)
Table 67.
Compare Output Mode, Phase Correct PWM Mode
COM21
COM20
Description
0
0
Normal port operation, OC2 disconnected.
0
1
Reserved
1
0
Clear OC2 on compare match when up-counting. Set OC2 on compare
match when downcounting.
1
1
Set OC2 on compare match when up-counting. Clear OC2 on compare
match when downcounting.
Table 68.
Clock Select Bit Description
CS22
CS21
CS20
Description
0
0
0
No clock source (Timer/Counter stopped)
0
0
1
clk
I/O
/(No prescaling)
0
1
0
clk
I/O
/8 (From prescaler)
0
1
1
clk
I/O
/64 (From prescaler)
1
0
0
clk
I/O
/256 (From prescaler)