11.07.2015 Views

ATMega chip full datasheet - UCSD Department of Physics

ATMega chip full datasheet - UCSD Department of Physics

ATMega chip full datasheet - UCSD Department of Physics

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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

ATmega48A/PA/88A/PA/168A/PA/328/Pcleared by s<strong>of</strong>tware (writing a logical one to the I/O bit location). For measuring frequency only,the clearing <strong>of</strong> the ICF1 Flag is not required (if an interrupt handler is used).16.7 Output Compare UnitsThe 16-bit comparator continuously compares TCNT1 with the Output Compare Register(OCR1x). If TCNT equals OCR1x the comparator signals a match. A match will set the OutputCompare Flag (OCF1x) at the next timer clock cycle. If enabled (OCIE1x = 1), the Output CompareFlag generates an Output Compare interrupt. The OCF1x Flag is automatically clearedwhen the interrupt is executed. Alternatively the OCF1x Flag can be cleared by s<strong>of</strong>tware 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 Waveform Generation mode(WGM13:0) bits and Compare Output mode (COM1x1:0) bits. The TOP and BOTTOM signalsare used by the Waveform Generator for handling the special cases <strong>of</strong> the extreme values insome modes <strong>of</strong> operation (See Section “16.9” on page 127.)A special feature <strong>of</strong> Output Compare unit A allows it to define the Timer/Counter TOP value (i.e.,counter resolution). In addition to the counter resolution, the TOP value defines the period timefor waveforms generated by the Waveform Generator.Figure 16-4 shows a block diagram <strong>of</strong> the Output Compare unit. The small “n” in the register andbit names indicates the device number (n = 1 for Timer/Counter 1), and the “x” indicates OutputCompare unit (A/B). The elements <strong>of</strong> the block diagram that are not directly a part <strong>of</strong> the OutputCompare unit are gray shaded.Figure 16-4.Output Compare Unit, Block DiagramDATA BUS (8-bit)TEMP (8-bit)OCRnxH Buf. (8-bit)OCRnxL Buf. (8-bit)TCNTnH (8-bit)TCNTnL (8-bit)OCRnx Buffer (16-bit Register)TCNTn (16-bit Counter)OCRnxH (8-bit)OCRnxL (8-bit)OCRnx (16-bit Register)= (16-bit Comparator )OCFnx (Int.Req.)TOPBOTTOMWaveform GeneratorOCnxWGMn3:0COMnx1:0The OCR1x Register is double buffered when using any <strong>of</strong> the twelve Pulse Width Modulation(PWM) modes. For the Normal and Clear Timer on Compare (CTC) modes <strong>of</strong> operation, thedouble buffering is disabled. The double buffering synchronizes the update <strong>of</strong> the OCR1x CompareRegister to either TOP or BOTTOM <strong>of</strong> the counting sequence. The synchronization8271D–AVR–05/11124

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

Saved successfully!

Ooh no, something went wrong!