Owner manual

101
ATmega8515(L)
2512A–AVR–04/02
howwaveforms are generated on the Output Compare outputsOC1x. For more details
about advancedcounting sequences andwaveformgeneration,see “Modes ofOpera-
tion” on page 106.
The
Timer/Counter Overflow
(TOV1)flag isset accordingtothemodeof operation
selectedbythe WGM13:0 bits.TOV1 can beusedfor generating a CPU interrupt.
Input Capture Unit TheTimer/Counter incorporates an input capture unit that can captureexternal events
and give them a time-stamp indicating time of occurrence. Theexternalsignal indicating
an event, or multiple events, can beapplied via the ICP1 pin or alternatively, via the
Analog Comparator unit. Thetime-stamps can then beused to calculate frequency,
duty-cycle, and otherfeatures of the signal applied.Alternatively thetime-stamps can be
usedforcreating a log of the events.
Theinput captureunitis illustratedbythe block diagram showninFigure48.Theele-
ments of the block diagram that are not directly a partof theinput captureunitaregray
shaded.The small “n” in register andbit names indicates theTimer/Counter number.
Figure 48. Input Capture Unit Block Diagram
When a change of the logiclevel(an event) occurs on the
Input Capture pin
(ICP1),
alternatively on the
Analog Comparator output
(ACO), and thischange confirms to the
setting of theedge detector, a capture will betriggered. When a captureis triggered, the
16-bit value of the counter(TCNT1) iswrittentothe
Input Capture Register
(ICR1).The
Input Capture Flag
(ICF1) isset at the same system clock as theTCNT1 value iscopied
into ICR1 Register. If enabled(TICIE1 = 1), the Input Capture Flag generates an input
captureinterrupt. The ICF1 flag is automatically clearedwhen theinterruptis executed.
Alternatively the ICF1 flag can be clearedbysoftware by writing a logical one to itsI/O
bit location.
Reading the16-bit value in the
Input Capture Register
(ICR1) isdone by first reading the
lowbyte (ICR1L) and then the highbyte (ICR1H). When the lowbyte isread the high
ICFn (Int.Req.)
Analog
Comparator
WRITE
ICRn (16-bit Register)
ICRnH (8-bit)
Noise
Canceler
ICPn
Edge
Detector
TEMP (8-bit)
DATA BUS (8-bit)
ICRnL (8-bit)
TCNTn (16-bit Counter)
TCNTnH (8-bit) TCNTnL (8-bit)
ACIC* ICNC ICES
ACO*