180
8331B–AVR–03/12
Atmel AVR XMEGA AU
Figure 14-16.
Dual-slope pulse width modulation.
Using dual-slope PWM results in a lower maximum operation frequency compared to the single-
slope PWM operation.
The period register (PER) defines the PWM resolution. The minimum resolution is 2 bits
(PER=0x0003), and the maximum resolution is 16 bits (PER=MAX).
The following equation calculate the exact resolution for dual-slope PWM (R
PWM_DS
):
The PWM frequency depends on the period setting (PER) and the peripheral clock frequency
(fclk
PER
), and can be calculated by the following equation:
N represents the prescaler divider used. The waveform generated will have a maximum fre-
quency of half of the peripheral clock frequency(fclkPER) when CCA is set to zero (0x0000) and
no prescaling is used. This also applies when using the hi-res extension, since this increases the
resolution and not the frequency.
14.8.5
Port Override for Waveform Generation
To make the waveform generation available on the port pins, the corresponding port pin direc-
tion must be set as output. The timer/counter will override the port pin values when the CC
channel is enabled (CCENx) and a waveform generation mode is selected.
shows the port override for a timer/counter. The timer/counter CC
channel will override the port pin output value (OUT) on the corresponding port pin. Enabling
inverted I/O on the port pin (INVEN) inverts the corresponding WG output.
CNT
MAX
TOP
Period (T)
BOTTOM
WG Output
CCx=BOTTOM
CCx
CCx=TOP
"match"
"update"
R
PWM_DS
PER
1
+
(
)
log
2
( )
log
-----------------------------------
=
f
PWM_DS
fclk
PER
2
N
PER
--------------------
=