Turn-key PCB assembly services in prototype quantities or low-volume to mid-volume production runs

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 mostly used timer in various applications. It is capable of operating as a simple counter, frequency generator including PWM, 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… Continue reading

Dealing with AVR timer interrupts

Probably you remember a great tutorial on programming external interrupts of AVR microcontrollers from Protostack. So here it is – next one on programming timer interrupts. In this particular case tutorial covers ATmega168 and similar AVRs. But techniques may be applied generally to all AVR MCUs. To be specific, write out covers short intro to timers and then leads to examples of several modes of operation including 8 and 16 bit timers. Examples are given in C language that can be compiled with AVR-GCC compiler. Hopefully you’ll find some good start in using them. Continue reading