
106
ATmega8515(L)
2512A–AVR–04/02
Compare Output Mode and
Waveform Generation
The Waveform Generator uses the COM1x1:0 bitsdifferently in Normal, CTC, and PWM
modes. For all modes, setting the COM1x1:0 = 0tells the Waveform Generator that no
action on the OC1x RegisterIsto be performed on thenext comparematch. Forcom-
pare output actions in the non-PWM modesrefer to Table50onpage 116. Forfast
PWM mode refer to Table51onpage 116, andforphase correctandphaseandfre-
quency correctPWM refer to Table52onpage 117.
A change of the COM1x1:0 bitsstate will have effectatthe first comparematch after the
bits are written. For non-PWM modes, theaction can be forced to have immediate effect
by using the FOC1xstrobe bits.
Modes of Operation Themodeof operation, i.e., the behavior of theTimer/Counter and the Output Compare
pins, isdefinedbythe combination of the
Waveform Generation mode
(WGM13:0) and
Compare Output mode
(COM1x1:0)bits.The Compare Output mode bitsdo not affect
the counting sequence,whilethe Waveform Generation mode bitsdo. The COM1x1:0
bitscontrolwhether thePWM output generatedshould beinverted or not (inverted or
non-inverted PWM). For non-PWM modes the COM1x1:0 bitscontrolwhether theout-
put should be set,cleared or toggleatacomparematch. See “Compare Match Output
Unit” on page 105.
Fordetailed timing information refer to “Timer/Counter Timing Diagrams”onpage 114.
Normal Mode The simplestmodeof operation is the
Normal
mode (WGM13:0 = 0). Inthis modethe
counting direction is always up(incrementing), and no counterclear isperformed.The
countersimply overrunswhen it passes its maximum 16-bit value (MAX=0xFFFF) and
then restartsfrom the BOTTOM (0x0000). Innormal operation the
Timer/Counter Over-
flow Flag
(TOV1)will be set in the same timerclock cycleas theTCNT1 becomeszero.
TheTOV1 flag in thiscase behaveslikea17thbit, exceptthat it is only set, not cleared.
However, combinedwith thetimer overflow interruptthat automatically clears theTOV1
flag, thetimerresolution can beincreasedbysoftware. Therearenospecialcases to
consider in thenormal mode, anewcounter value can be written anytime.
Theinput capture unit is easy to useinNormal mode. However, observe that themaxi-
mum intervalbetween theexternal events must not exceed the resolution of the counter.
If theintervalbetween events aretoolong, thetimer overflow interruptor the prescaler
must beused to extend the resolution for the captureunit.
The output compareunitscan beused to generate interrupts at some given time. Using
the output comparetogenerate waveforms in Normal modeis not recommended, since
thiswill occupy too much of the CPU time.
Comentarios a estos manuales