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

8-bit Timer/Counter0 operation modes.Part2

Previously we have revealed only two Timer/Counter0 modes: Normal and CTC. So far there are a couple more useful working modes Fast PWM and Phase Correct PWM. These modes are even more complicated comparing to what we know. But let’s not get scared of this and go through these modes step by step. First of all, let’s remember the basics of what PWM is and then do some practical stuff. Short intro to PWM Pulse Width Modulation (PWM) is a widely used technique for digitally controlling analog circuits. When talking analog circuits – these include lamps, motors, power converters and more. For instance, simple DC motor speed can be adjusted by varying a supply voltage. But imagine what circuitry would be to do this through the microcontroller. To make things… Continue reading

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