PWM s Atmega128

zdravim vas mam maly problem s PWMkem

potrebuju ovladat 2 serva pouzivam fazove korigovane PWM

vypoctove mam vse ok ale jak mile zacnu nastavovat OCR3A a OCR3B pro serva tak se mi nehnou. Jakmile OCR3B drzim na 0 tak PWM bez problemu jede poradi nekdo co s tim

[code]

int main (void)
{

DDRE = 0x18; //povoleni portu PE3 a PE4 jako vystup PWM (OC3A a OC3B)
ICR3=18432;
TCCR3A=0xA0;
TCCR3B=0x12;
TCNT3H=0x00;
TCNT3L=0x00;
OCR3A=1222;
OCR3B=1222;

u08 line = 0;

init();
delay_1ms_u16(20);
init_lcd();

clear_disp();

int pruchod;
int natoceni1;
int natoceni2;
char info1[20];
char info2[20];
char info3[20];
int senzor=1;
unsigned int vysledek;
unsigned int prepocet;
unsigned char kanal = 0b01000000; //0x40; 0b01000000; ADC0

ADCSRA = 0x87;  
key = 0;
while(1){

sprintf(info1, "Servo 1:  %d",OCR3A);
		sprintf(info2, "Servo 2:  %d",OCR3B);

clear_disp();
put_string_xy(0, 0, info1);
cursor_disp_ctrl(0x04);
put_string_xy(0, 1, info2);

		while (key == 0);
//inkrementovat pruchod

 	if (key != 0) {
		switch (key) {
			case 0x11 : {OCR3A+=1;}; break;		// 1
			case 0x12 : {OCR3A+=10;}; break;		// 2
			case 0x14 : {OCR3A+=100;}; break;		// 3
			case 0x21 : {OCR3A-=1;}; break;		// 4
			case 0x22 : {OCR3A-=10;}; break;		// 5
			case 0x24 : {OCR3A-=100;}; break;		// 6
			case 0x41 : {OCR3B+=1;}; break;		// 7
			case 0x42 : {OCR3B+=10;}; break;		// 8
			case 0x44 : {OCR3B+=100;}; break;		// 9
			case 0x82 : {OCR3B-=10;}; break;		// 0
			case 0x81 : {OCR3B-=1;}; break;		// *
			case 0x84 : {OCR3B-=100;}; break;		// #
			case 0x18 :return(1);break; 						// ESC
			
					}

		//pipani
		key = 0;
		beep(200, 10);

		

				
		//***********************************		
		if(OCR3A>=2122) OCR3A=2122;  
		if(OCR3B>=2122) OCR3B=2122;
		if(OCR3A<=522) OCR3A=522;
		if(OCR3B<=522) OCR3B=522;
		
				 						
				}		  	  			
	
		   }		

_delay_ms(400);
}[/code]

Problem je v tom ze se mi generuji po sobe nejdriv OCR3A a potom OCR3B ale netusim jak je donutit zaroven