197
8331B–AVR–03/12
Atmel AVR XMEGA AU
The PER register defines the PWM resolution. The minimum resolution is two bits
(PER=0x0003), and the maximum resolution is eight bits (PER=MAX).
The following equation is used to calculate the exact resolution for a single-slope PWM
(R
PWM_SS
) waveform:
The single, slow PWM frequency (f
PWM_SS
) depends on the period setting (PER) and the periph-
eral clock frequency (f
PER
), and it is calculated by using the following equation:
where N represents the prescaler divider used (1, 2, 4, 8, 64, 256, 1024, or event channel n).
15.6.3
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 CMP
channel is enabled (LCMPENx/HCMPENx).
shows the port override for the low- and high-byte timer/counters. For
the low-byte timer/counter, CMP channels A to D will override the output value (OUTxn) of port
pins 0 to 3 on the corresponding port pins (Pxn). For the high-byte timer/counter, CMP channels
E to H will override port pins 4 to 7. Enabling inverted I/O on the port pin (INVENxn) inverts the
corresponding WG output.
Figure 15-6.
Port override for low- and high-byte timer/counters.
15.7
Interrupts and Events
The timer/counters can generate interrupts and events. The counter can generate an interrupt
on underflow, and each CMP channel for the low-byte counter has a separate compare interrupt.
Events will be generated for all conditions that can generate interrupts. For details on event gen-
eration and available events, refer to
R
PWM_SS
PER
1
+
(
)
log
2
( )
log
-----------------------------------
=
f
PWM_SS
f
PER
N
PER
1
+
(
)
-------------------------------
=
OUT
LCMPENx /
HCMPENx
INVEN
OCx
Waveform