// TIMER/COUNTER 0
// PIN 6(OC0A) = NON-INVERTED [_BV(COM0A1)]
// PIN 5(OC0B) = INVERTED [_BV(COM0B1) | _BV(COM0B0)]
// PWM MODE = FAST PWM [_BV(WGM01) | _BV(WGM00)]
// PRESCALER = 1 [_BV(CS00)]
TCCR0A = _BV(COM0A1) | _BV(COM0B1) | _BV(COM0B0) | _BV(WGM01) | _BV(WGM00);
TCCR0B = _BV(CS00);
// TIMER/COUNTER 1
// PIN 9(OC1A) = ?????
// PIN 10(OC1B) = ?????
// PWM MODE = FAST PWM 8BIT[_BV(WGM12) | _BV(WGM10)]
// PRESCALER = 1 [_BV(CS10)]
TCCR1A = ????? | _BV(WGM10);
TCCR1B = _BV(WGM12) | _BV(CS10);
// TIMER/COUNTER 2
// PIN 11(OC2A) = NON-INVERTED [_BV(COM2A1)]
// PIN 3(OC2B) = NON-INVERTED [_BV(COM2B1)]
// PWM MODE = FAST PWM [_BV(WGM21) | _BV(WGM20)]
// PRESCALER = 1 [_BV(CS20)]
TCCR2A = _BV(COM2A1) | _BV(COM2B1) | _BV(WGM21) | _BV(WGM20);
TCCR2B = _BV(CS20);
Hi. My intention of writing the codes is to clarify my doubts regarding arduino timer.
First of all, I intend to have 6 consistent PWM outputs which is 8 bits and runs at 62.5kHz. The confusion here is FAST PWM and PHASE CORRECT PWM. TIMER 1 and 2 is usually presented as PHASE CORRECT PWM. So does changing the PWM mode of TIMER 1 and 2 to FAST PWM enables the PWM to reach a frequency of 62.5kHz (prescaler set as 1)? Is the code that I have written correct? Do take note of the inverted and non-inverted pin mode.
Secondly, as seen from my code above, Timer/Counter 1 is not properly written (?????). I wish to control pin 9 and 10 so that it can invert or non-invert individually. Timer 0 and 2 allows me to set the pins individually (inverted and non-inverted). However from the atmega328p datasheet, Timer 1 control register is weird. How can I set the register so that I can do what I want to do which is to control the pins individually?
I truly apologize for any confusion caused by my sentence structure. I am aware I have a poor way of organizing and presenting my idea. And lastly, thank you for taking your time reading these doubt of mine.