no problem rc servo in code.
// use clock 20mhz atmega328
ISR(TIMER3_COMPA_vect)
{
OCR3A = 5000; // 2500 = 1.0ms 3750 = 1.5ms 5000 = 2.0ms
}
void main(void)
{
// Timer1 (16bit) @ 2.5MHZ //
TCCR1A = (1 << COM1A1) | (1 << WGM11);
TCCR1B = (1 << WGM12) | (1 << WGM13) | (1 << CS11);
TIMSK1 = (1 << OCIE1A);
ICR1 = 50000;
}
other problem 8ch rc servo in code ???..ooo
unsigned int servopwm[10];
unsigned int servoindex;
unsigned int tcount;
ISR(TIMER3_COMPA_vect)
{
if(servoindex <=7) PORTA &= ~(1 << servoindex);
servoindex++;
if(servoindex == 8) servoindex = 0;
tcount++;
if(tcount >= servopwm[servoindex])
PORTA &= ~(1 << servoindex);
else
PORTA |= (1 << servoindex);
OCR3AH = servopwm[servoindex] >> 8;
OCR3AL = servopwm[servoindex] & 0xFF;
}
void main( void )
{
// Timer1 (16bit) @ 2.5MHZ //
TCCR1A = (1 << WGM31);
TCCR1B = (1 << WGM12) | (1 << WGM13) | (1 << CS11);
TIMSK1 = (1 << OCIE1A);
ICR1 = 50000;
servopwm[0] = 2500;
servopwm[1] = 3750;
servopwm[2] = 2500;
servopwm[3] = 5000;
....
}
who? please help me??? no easy…