21.08.2013 Views

Embedded Systems Design with the Atmel AVR Microcontroller Part II

Embedded Systems Design with the Atmel AVR Microcontroller Part II

Embedded Systems Design with the Atmel AVR Microcontroller Part II

SHOW MORE
SHOW LESS

Create successful ePaper yourself

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

6.6. TIMER 0 SYSTEM 147<br />

internally via <strong>the</strong> microcontroller’s main clock (fclk_I/O). This clock frequency may be too rapid<br />

for many applications. Therefore, <strong>the</strong> timing system is equipped <strong>with</strong> a prescaler to subdivide <strong>the</strong><br />

main clock frequency down to timer system frequency (clkTn). The clock source for Timer 0 is<br />

selected using <strong>the</strong> CS0[2:0] bits contained in <strong>the</strong> Timer/Counter Control Register B (TCCR0B).<br />

The TCCR0A register contains <strong>the</strong> WGM0[1:0] bits and <strong>the</strong> COM0A[1:0] (and B) bits. Whereas,<br />

<strong>the</strong> TCCR0B register contains <strong>the</strong> WGM0[2] bit.These bits are used to select <strong>the</strong> mode of operation<br />

for Timer 0 as well as tailor waveform generation for a specific application.<br />

Figure 6.6: Timer 0 block diagram. Figure used <strong>with</strong> permission <strong>Atmel</strong>, Inc.<br />

The timer clock source (clkTn) is fed to <strong>the</strong> 8-bit Timer/Counter Register (TCNT0). This<br />

register is incremented (or decremented) on each clkTn clock pulse. Timer 0 is also equipped <strong>with</strong><br />

two 8-bit comparators that constantly compares <strong>the</strong> numerical content of TCNT0 to <strong>the</strong> Output<br />

Compare Register A (OCR0A) and Output Compare Register B (OCR0B). The compare signal<br />

from <strong>the</strong> 8-bit comparator is fed to <strong>the</strong> waveform generators. The waveform generators have a<br />

number of inputs to perform different operations <strong>with</strong> <strong>the</strong> timer system.

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

Saved successfully!

Ooh no, something went wrong!