I'm trying to get this program to use channel B for the output waveform using the phase correct PWM mode and using OCR1A as the top. With a 50% duty ratio I'm attempting to get a 10 Hz freq. I'm able to adjust the OC1A (Pin 9) if I set TCCR1A to 0x43; but nothing comes from pin 10. Code:

include "avr/io.h"

void setup()  
 DDRB = 0x6; //set pins 9 and 10 as output  

 /*set operation Toggle mode; WGM13:0 = 1011 phase correct PWM  
CS12:0 = 101 prescaler = 1024*/
 TCCR1A = 0x23;  
 TCCR1B = 0x15;

 OCR1A = 0x187; //391 for 50% duty cycle  
 TCNT1 = 0; //clear counter and update OCR1A  
void loop()  
{ }
  • It's much more readable to configure registers using bit operations like TCCR1A |= (1<<COM1A1);. Pin 10 refers to the arduino's pin 10?
    – Sim Son
    Nov 5, 2019 at 16:12
  • Haven't looked into the spec but maybe you want to try setting OCR1AL = 0x87 and OCR1AH = 0x01 separately.
    – Kwasmich
    Nov 6, 2019 at 7:32

1 Answer 1


You are using Timer/Counter 1 in Fast PWM Mode with TOP set to OCR1A:
OCR1Aonly describes the number to what it counts up so, 0…391 in your case.
You have to define the duty cycle with OCR1B. 50% would be 195.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.