I have some troubles trying to run Fast PWM on OC0A and OC2A pins.
The code is the following:
TCNT0 = 0; TCNT2 = 76/2; OCR0B = 76; OCR2B = 76; OCR0A = 10; OCR2A = 10; TCCR0A = 0b11000011; TCCR2A = 0b10000011; TCCR0B = 0b1010; TCCR2B = 0b1010;
So I assume that timers will run with 1:8 speed from 0 (and 38 for Timer 2) to the top defined by OCRxB registers (76) and will change pins state on TOP (76) and OCRxA (10).
That's not work: the pins OC0A and OC2A connecting to the timers (as I can not change their state by putting 1 and 0 into respecting PORTD and PORTB bits) but there is no PWM signal.
However if I try to use OC0B and OC2B pins - everything works:
TCNT0 = 0; TCNT2 = 76/2; OCR0A = 76; OCR2A = 76; OCR0B = 10; OCR2B = 10; TCCR0A = 0b00110011; TCCR2A = 0b00100011; TCCR0B = 0b1010; TCCR2B = 0b1010;
Need to note that in this case OC0A and OC2A pins can be driven directly by changing the pin state (which proofs that I don't have any schematic flaws).
I tried to replace the values of OCRxA and OCRxB in first code but that didn't help:
TCNT0 = 0; TCNT2 = 76/2; OCR0A = 76; OCR2A = 76; OCR0B = 10; OCR2B = 10; TCCR0A = 0b11000011; TCCR2A = 0b10000011; TCCR0B = 0b1010; TCCR2B = 0b1010;
Sorry for omitting part of the code. The ports definitions goes before the main code:
DDRB = 0b00001010; PORTB = 0b11110101; DDRC = 0b0000000; PORTC = 0b1111110; DDRD = 0b01101000; PORTD = 0b10010011;