complimentary PWM 50Hz

Hai,

I am on the work of a quick prototype of inverter and I trying for a complimentary PWM. By searching in different forum threads I reached the below code .The below code is for 30Hz and 122Hz or higher. But I want a 50-60Hz pulse . Please help me to change it into a 50hz pulse.

word ADC_val=100; word val;

TCCR1A = (TCCR1A & 0x0F) | 0xB0 ; TCCR1B = _BV(CS00) | _BV(CS02); TCCR1B = (TCCR1B & 0xF8) | 5;//6-122Hz,5-30hz analogWrite (9, ADC_val) ; analogWrite (10, 255-ADC_val) ;

Use WGM3:0 = 12 or 14, these use the 16-bit register ICR1 as TOP so you can adjust how many clocks it takes.

However, when you do this, you can't use analogWrite() anymore, since the values are no longer from 0~255 - but the code to do this isn't anything special, just a matter of setting the OCR1x registers directly (analogWrite() limits the values to between 0 and 255. See pg 112~138 of the datasheet, or look for the TimerOne library that provides some wrappers around direct register manipulation.

If I understand you correctly you want one PWM output and one output that is 0 as long as the PWM output is 1 and 1 as long as the PWM output is 0. Correct? If so you could just use a NOT gate like the 7404 or something similar.