12.07.2015 Views

ATmega32A Datasheet - Sunrom Technologies

ATmega32A Datasheet - Sunrom Technologies

ATmega32A Datasheet - Sunrom Technologies

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>ATmega32A</strong>Figure 17-2.DATA BUSCounter Unit Block DiagramTOVn(Int.Req.)TCNTncountcleardirectionControl Logicclk TnPrescalerT/COscillatorTOSC1TOSC2bottomtopclk I/OSignal description (internal signals):count Increment or decrement TCNT2 by 1.directionclearclk T2topbottomSelects between increment and decrement.Clear TCNT2 (set all bits to zero).Timer/Counter clock.Signalizes that TCNT2 has reached maximum value.Signalizes that TCNT2 has reached minimum value (zero).Depending on the mode of operation used, the counter is cleared, incremented, or decrementedat each timer clock (clk T2 ). clk T2 can be generated from an external or internal clock source,selected by the Clock Select bits (CS22:0). When no clock source is selected (CS22:0 = 0) thetimer is stopped. However, the TCNT2 value can be accessed by the CPU, regardless ofwhether clk T2 is present or not. A CPU write overrides (has priority over) all counter clear orcount operations.The counting sequence is determined by the setting of the WGM21 and WGM20 bits located inthe Timer/Counter Control Register (TCCR2). There are close connections between how thecounter behaves (counts) and how waveforms are generated on the Output Compare outputOC2. For more details about advanced counting sequences and waveform generation, see“Modes of Operation” on page 124.The Timer/Counter Overflow (TOV2) Flag is set according to the mode of operation selected bythe WGM21:0 bits. TOV2 can be used for generating a CPU interrupt.17.5 Output Compare UnitThe 8-bit comparator continuously compares TCNT2 with the Output Compare Register(OCR2). Whenever TCNT2 equals OCR2, the comparator signals a match. A match will set theOutput Compare Flag (OCF2) at the next timer clock cycle. If enabled (OCIE2 = 1), the OutputCompare Flag generates an output compare interrupt. The OCF2 Flag is automatically clearedwhen the interrupt is executed. Alternatively, the OCF2 Flag can be cleared by software by writinga logical one to its I/O bit location. The waveform generator uses the match signal togenerate an output according to operating mode set by the WGM21:0 bits and Compare Outputmode (COM21:0) bits. The max and bottom signals are used by the waveform generator for handlingthe special cases of the extreme values in some modes of operation (“Modes of Operation”on page 124). Figure 17-3 shows a block diagram of the output compare unit.8155C–AVR–02/11121

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!