Mein Code sieht nun wie folgt aus, aber das funktioniert gar nicht mehr...
Ich kriegs irgendwie echt nicht hin
Code:#include <avr/io.h> // I/O Port definitions #include <avr/interrupt.h> // Interrupt macros #define F_CPU 16000000 #define timer 96 //0.01ms // volatile int ms1 = 0; volatile int ms2 = 0; volatile int ms3 = 0; void timer_init(void) { TCCR0 |= (1<<CS01); //Prescaler 8 TCNT0 = timer; TIMSK |= (1<<TOIE0); //Interupts aktivieren TIFR |= (1<<TOV0); }; ISR(TIMER0_OVF_vect) { TCNT0 = timer; //Endausschlag LINKS if(ms1>=150) PORTB &= ~(1<<PORTB1); else PORTB |= (1<<PORTB1); if(ms1<=2000) ms1++; else ms1 = 0; TCNT0 = timer; if(ms2>=150) PORTB &= ~(1<<PORTB2); else PORTB |= (1<<PORTB2); if(ms2<=2000) ms2++; else ms2 = 0; if(ms3>=150) PORTB &= ~(1<<PORTB3); else PORTB |= (1<<PORTB3); if(ms3<=2000) ms3++; else ms3 = 0; }; int main(void) { sei(); timer_init(); DDRB |= (1<<PORTB1) | (1<<PORTB2) | (1<<PORTB3); //B... AUSGANG PORTB &= ~((1<<PORTB1) | (1<<PORTB2) | (1<<PORTB3)); //B.. Low //GLOBALE INTERUPTS AKTIVIERT while(1) { } }







Zitieren

Lesezeichen