Datasheet
154
ATmega16U4/32U4 [DATASHEET]
Atmel-7766J-USB-ATmega16U4/32U4-Datasheet_04/2016
A frequency (with 50% duty cycle) waveform output in fast PWM mode can be achieved by setting the
Waveform Output (OCW4x) to toggle its logical level on each Compare Match (COM4x1:0 = 1). The waveform
generated will have a maximum frequency of f
OC4
= f
clkT4
/4 when OCR4C is set to three.
The general I/O port function is overridden by the Output Compare value (OC4x / OC4x
) from the Dead Time
Generator, if either of the COM4x1:0 bits are set and the Data Direction Register bits for the OC4X and OC4X
pins are set as an output. If the COM4x1:0 bits are cleared, the actual value from the port register will be visible
on the port pin. The Output Compare Pin configurations are described in the table below.
15.8.3 Phase and Frequency Correct PWM Mode
The Phase and Frequency Correct PWM Mode (PWM4x = 1 and WGM40 = 1) provides a high resolution Phase
and Frequency Correct PWM waveform generation option. The Phase and Frequency Correct PWM mode is
based on a dual-slope operation. The counter counts repeatedly from BOTTOM to TOP (defined as OCR4C)
and then from TOP to BOTTOM. In non-inverting Compare Output Mode, and in complimentary Compare
Output Mode, the Waveform Output (OCW4x) is cleared on the Compare Match between TCNT4 and OCR4x
while upcounting, and set on the Compare Match while down-counting. 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 symmetric feature of the dual-slope PWM modes, these modes are preferred for
motor control applications.
The timing diagram for the Phase and Frequency Correct PWM mode is shown on Figure 15-14 in which the
TCNT4 value is shown as a histogram for illustrating the dual-slope operation. The counter is incremented until
the counter value matches TOP. When the counter reaches TOP, it changes the count direction. The TCNT4
value will be equal to TOP for one timer clock cycle. The diagram includes the Waveform Output (OCW4x) in
non-inverted and inverted Compare Output Mode. The small horizontal line marks on the TCNT4 slopes
represent Compare Matches between OCR4x and TCNT4.
Table 15-2. Output Compare Pin Configurations in Fast PWM Mode
COM4x1 COM4x0 OC4x Pin OC4x Pin
0 0 Disconnected Disconnected
0 1 OC4x OC4x
1 0 Disconnected OC4x
1 1 Disconnected OC4x