Rainbow-electronics ATmega8515L Uživatelský manuál Strana 84

  • Stažení
  • Přidat do mých příruček
  • Tisk
  • Strana
    / 223
  • Tabulka s obsahem
  • KNIHY
  • Hodnocené. / 5. Na základě hodnocení zákazníků
Zobrazit stránku 83
84
ATmega8515(L)
2512A–AVR–04/02
Figure 38. FastPWM Mode, Timing Diagram
TheTimer/CounterOverflowFlag (TOV0) isset each time the counterreachesMAX. If
theinterruptis enabled, theinterrupt handlerroutine can beusedfor updating the com-
parevalue.
In fastPWM mode, the compare unit allows generation of PWM waveforms on the OC0
pin. Setting the COM01:0 bits to 2 will produceanon-inverted PWM and an inverted
PWM output can be generatedbysetting the COM01:0to3(See Table46 on page 89).
TheactualOC0value will only bevisibleonthe port pin if the data direction for the port
pin isset as output. ThePWM waveformis generatedbysetting (orclearing) the OC0
Register at the comparematch between OCR0 and TCNT0, andclearing (orsetting) the
OC0Register at thetimerclock cyclethe counter iscleared(changesfrom MAX to
BOTTOM).
ThePWM frequency for the output can be calculatedbythe following equation:
The“
N
”variable represents the prescale factor(1, 8,64, 256, or 1024).
Theextreme valuesfor the OCR0 Registerrepresentsspecialcaseswhen generating a
PWM waveformoutput in the fastPWM mode. If the OCR0 isset equal to BOTTOM, the
output will beanarrowspike for each MAX+1timerclock cycle. Setting the OCR0 equal
to MAXwill resultinaconstantly high orlow output (dependingonthe polarity of the out-
put set by the COM01:0 bits).
A frequency (with 50%duty cycle)waveform output in fastPWM mode can beachieved
by setting OC0totoggleitslogicallevel on each comparematch (COM01:0 = 1).The
waveformgeneratedwill have a maximum frequency off
OC0
=f
clk_I/O
/2 when OCR0 is
set to zero. Thisfeatureissimilar to the OC0toggleinCTC mode, exceptthe double
bufferfeatureof theoutput compareunitis enabled in the fastPWM mode.
TCNTn
OCRn Update and
TOVn Interrupt Flag Set
1
Period
2 3
OCn
OCn
(COMn1:0 = 2)
(COMn1:0 = 3)
OCRn Interrupt Flag Set
4 5 6 7
f
OCnPWM
f
clk_I/O
N 256
------------------=
Zobrazit stránku 83
1 2 ... 79 80 81 82 83 84 85 86 87 88 89 ... 222 223

Komentáře k této Příručce

Žádné komentáře