8-bit Timer/Counter0 operation modes.Part1

As our selected Atmega328 microcontroller has three timers, I think it is best to analyze them separately. Timer/Counter0 is probably mainly used the timer in various applications. It is capable of operating as a simple counter, frequency generator including PWM, and external source clock counter and can generate tree interrupts: one overflow (TOV0) and two independent output compare match interrupts (OCF0A and OCF0B). As you see Timer/Counter0 register, TCN0 has two 8 bit double buffered Output Compare Registers (OCR0A and OCR0B) associated that can be used to generate two different waveforms on microcontroller pins OC0A and OC0B and two interrupts (OCF0A and OCF0B) as well. Each timer interrupt can be enabled individually in TIMSK0 register by setting bits to one. TIFR0 register holds bits indicating interrupt request signals. And, of course, there are two more essential registers, TCCR0A and TCCR0B. These are used to set timer operation modes, set prescallers, and start timer itself. It would take lots of space to go into details describing these registers – besides, all info is nicely plotted in datasheets. Better focus on some…

Continue reading