English
Language : 

ATMEGA64_08 Datasheet, PDF (154/393 Pages) ATMEL Corporation – 8-bit Microcontroller with 64K Bytes In-System Programmable Flash
ing. In inverting Output Compare mode, the operation is inverted. The dual-slope operation has
lower maximum operation frequency than single slope operation. However, due to the symmet-
ric feature of the dual-slope PWM modes, these modes are preferred for motor control
applications.
The PWM resolution for the phase correct PWM mode is fixed to eight bits. In phase correct
PWM mode the counter is incremented until the counter value matches MAX. When the counter
reaches MAX, it changes the count direction. The TCNT2 value will be equal to MAX for one
timer clock cycle. The timing diagram for the phase correct PWM mode is shown on Figure 67.
The TCNT2 value is in the timing diagram shown as a histogram for illustrating the dual-slope
operation. The diagram includes non-inverted and inverted PWM outputs. The small horizontal
line marks on the TCNT2 slopes represent Compare Matches between OCR2 and TCNT2.
Figure 67. Phase Correct PWM Mode, Timing Diagram
OCn Interrupt
Flag Set
OCRn Update
TOVn Interrupt
Flag Set
TCNTn
OCn
OCn
(COMn1:0 = 2)
(COMn1:0 = 3)
Period
1
2
3
The Timer/Counter Overflow Flag (TOV2) is set each time the counter reaches BOTTOM. The
interrupt flag can be used to generate an interrupt each time the counter reaches the BOTTOM
value.
In phase correct PWM mode, the compare unit allows generation of PWM waveforms on the
OC2 pin. Setting the COM21:0 bits to two will produce a non-inverted PWM. An inverted PWM
output can be generated by setting the COM21:0 to three (see Table 67 on page 159). The
actual OC2 value will only be visible on the port pin if the data direction for the port pin is set as
output. The PWM waveform is generated by clearing (or setting) the OC2 Register at the Com-
pare Match between OCR2 and TCNT2 when the counter increments, and setting (or clearing)
the OC2 Register at Compare Match between OCR2 and TCNT2 when the counter decrements.
The PWM frequency for the output when using phase correct PWM can be calculated by the fol-
lowing equation:
fOCnPCPWM = N-f--c---l⋅-k--5_---I1-/-O--0-
154 ATmega64(L)
2490N–AVR–05/08