Help understanding timers

Hi guys,

This probably seems very simple to you but I'm having trouble understanding this TIMER 2 section on an example code I've been given - it makes no sense at all to me!

//TIMER 2//
//TCCR2A COM2A1+COM2B1 = clear OCOA and 0C0B on match set OCOA and 0C0B at BOTTOM, WGM2 bit 0 and 1 = mode 3 fast PWM

TCCR2A = _BV(COM2A1) | _BV(COM2B1)| _BV(WGM21) | _BV(WGM20);
TCCR2B = _BV(CS22); // Bit Value; Timer Counter Control Register

It's for a line following robot - I've configured the pins for input and output and stuff, and understand the calibration etc., just don't get this bit!

Thanks a lot :slight_smile:

If you're going to play with arduino for very long you'll need this document. Section 18 is the one on timer 2. The description of the registers starts on page 153 but I would try to read the entire section. It is kind of a dry read, it might take 2 or 3 times through to really get it. BUt spend a day with this and you'll be a master of the timers on an arduino.

You may also wish to breeze over to Max's webpages and review all the timers:


Timer 1

Timer 2

My Projects