179
XMEGA B [DATASHEET]
8291B–AVR–01/2013
14.6.1 Waveform Generation
The compare channels can be used for waveform generation on the corresponding port pins. To make the waveform
visible on the connected port pin, the following requirements must be fulfilled:
1.
The compare channels to be used must be enabled. This will override the corresponding port pin output register.
2.
The direction for the associated port pin must be set to output.
Inverted waveform output can be achieved by setting invert I/O on the port pin. Refer to
details.
14.6.2 Single-slope PWM Generation
For PWM generation, the period (T) is controlled by the PER register, while the CMPx registers control the duty cycle of
the waveform generator (WG) output.
shows how the counter counts from TOP to BOTTOM,
and then restarts from TOP. The WG output is set on the compare match between the CNT and CMPx registers, and
cleared at BOTTOM.
Figure 14-5. Single-slope pulse width modulation.
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 peripheral 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).
14.6.3 Port Override for Waveform Generation
To make the waveform generation available on the port pins, the corresponding port pin direction 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.
CNT
MAX
TOP
Period (T)
"match"
BOTTOM
WG Output
CMPx=BOT
CMPx
CMPx=TOP
R
PWM_SS
PER
1
+
log
2
log
---------------------------------
=
f
PWM_SS
f
PER
N
PER
1
+
------------------------------
=
Содержание XMEGA B
Страница 320: ...320 XMEGA B DATASHEET 8291B AVR 01 2013 Table 25 12 7 segments Character Table...
Страница 321: ...321 XMEGA B DATASHEET 8291B AVR 01 2013 Table 25 13 14 segments Character Table...
Страница 322: ...322 XMEGA B DATASHEET 8291B AVR 01 2013 Table 25 14 16 segments Character Table...
Страница 412: ...412 XMEGA B DATASHEET 8291B AVR 01 2013...
Страница 413: ...413 XMEGA B DATASHEET 8291B AVR 01 2013...
Страница 414: ...414 XMEGA B DATASHEET 8291B AVR 01 2013...