Hallo

Ich lese nun schon seit ein paar Tagen mit und verstehe nicht, warum ihr nicht einfach den Beispielcode aus dem RN-Wissen zu den Servos verwendet. Ein Timer im CTC-Mode und eine kleine ISR dazu steuert mehrere Servos, z.B. ein ATMega32 mit 8MHz und drei Servos:

Code:
#include <avr/io.h>			// I/O Port definitions
#include <avr/interrupt.h>	// Interrupt macros

uint8_t  x, y, z;

void init(void)
{
	DDRA |= 16;				// E_INT1 als Ausgang
	DDRC |= 3;				// SCL und SDA als Ausgang

	TCCR0 =  (0 << WGM00) | (1 << WGM01);					// CTC-Mode
	TCCR0 |= (0 << COM00) | (0 << COM01);					// ohne OCR-Pin
	TCCR0 |= (0 << CS02)  | (1 << CS01) | (0 << CS00);	// prescaler /8
	TIMSK =  (1 << OCIE0); 										// Interrupt ein
	OCR0  = 9; // 100kHz?
	sei();
}
ISR(TIMER0_COMP_vect)
{
	static uint16_t count=0;
	if(count>z) PORTA &= ~16; else PORTA |= 16;	// E_INT1 (Pin8)
	if(count>y) PORTC &= ~1;  else PORTC |= 1;	// SCL (Pin10)
	if(count>x) PORTC &= ~2;  else PORTC |= 2;	// SDA (Pin12)
	if(count<2000)count++; else count=0;
}
int main(void)
{
	init();
	x=y=z=100;
	while(1);
	return 0;
}
Gruß

mic