My goal is to have a fixed frequency output where I can vary only the duty. I want to pass the pulse train through a low pass filter to get a variable dc output. Having more than 256 possible values is preferred, which is why I want 1024 values.
TCCR1A = _BV(COM1A0) | _BV(COM1B1) | _BV(WGM11) | _BV(WGM20);
TCCR1B = _BV(WGM12) | _BV(CS12);
OCR2A = 1024;
OCR2B = 50;
I would be setting the upper end to 1024, and here I have a 50+1/1024+1 duty cycle on digital pin 10. Is this correct? Will this accomplish the task, or do I need lower-level programming on the registers?
Which frequency do you want and what timer mode are you trying to use (looks like fast pwm, 10-bit)? Off the top of my head, it seems like the phase & frequency correct mode might produce PWM signals that are better for filtering.
Note that your code is using WGM20 instead of WGM10. Also, two of the registers you are writing to are for timer2, not timer1 (OCR2A & B). I believe your current settings would result in a 16 Hz frequency (CS12 selects the 1/1024 prescaler to go with your fixed 0x3FF TOP value in fast PWM, 10-bit mode). This is probably slower than you want. Once you have the frequency selected, you would want to use OCR1A & B to set the duty cycle of your two output pins. Finally, the COM1A0 bit you set is actually disabling that PWM function. You probably want COM1A1 to get a normal PWM output. Set both A1 & A0 (or B1 & B0 for the other output) to get an inverted PWM signal.