
160
XMEGA A [MANUAL]
8077I–AVR–11/2012
4.
The direction for the associated port pin must be set to output.
Inverted waveform output is achieved by setting the invert output bit for the port pin.
14.8.2 Frequency (FRQ) Waveform Generation
For frequency generation the period time (T) is controlled by the CCA register instead of PER. The waveform generation
(WG) output is toggled on each compare match between the CNT and CCA registers, as shown in
Figure 14-14 on pageFigure 14-14.Frequency waveform generation.
The waveform frequency (fFRQ) is defined by the following equation:
where N represents the prescaler divider used. The waveform generated will have a maximum frequency 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.3 Single-slope PWM Generation
For single-slope PWM generation, the period (T) is controlled by PER, while CCx registers control the duty cycle of the
WG output.
Figure 14-15 shows how the counter counts from BOTTOM to TOP and then restarts from BOTTOM. The
waveform generator (WG) output is set on the compare match between the CNT and CCx registers and cleared at TOP.
Figure 14-15.Single-slope pulse width modulation.
CNT
MAX
"update"
TOP
CNT written
Direction Change
Period (T)
BOTTOM
WG Output
f
FRQ
fclk
PER
2N CCA
1
+
----------------------------------
=
CNT
MAX
TOP
Period (T)
"match"
BOTTOM
WG Output
CCx=BOTTOM
CCx
CCx=TOP
"update"