hier ist mein CODE
Code:/************************************************************************* * * .C /************************************************************************* * * .C * *************************************************************************/ /************************************************************************* * History * * Date Name Description *------------------------------------------------------------------------- * 05656 CHIS created * *************************************************************************/ #include <avr\io.h> // Wir brauchen Zugriff auf die I/O's des Controllers #include <avr\signal.h> #include <avr\interrupt.h> #include <avr\eeprom.h> // Und auf das Flash #include <inttypes.h> volatile int timer_flag, s; int i, t1s; #define FCLOCK 8000000 // Timer 0 // presc. = 1024 // incr. = 7.813kHz bzw. 0.12ms #define TCNT0_Reload (256-(FCLOCK/256)/100) /************************************************************************* * * für Quartz 8.000MHz * *************************************************************************/ SIGNAL(SIG_OVERFLOW0) { outb(TCNT0, TCNT0_Reload); // timer neu laden timer_flag = 1; } int main(void) { /******* FÜR UART********/ outb(DDRC, 0xff); outb(DDRD, 0xff); /* * MainLoop * Timer 1 initialisieren */ //outb(TCNT0, TCNT0_Reload); outb(TCCR0, 0x03); //1024= 7.813 KHz outb(TIMSK, inb(TIMSK) | BV(TOIE0)); /* enable T0 IRQ */ // BV (1<<TOIE0) // gloabel IRQ-Bit setzen sei(); /************************************************************************* * MAIN_Loop */ for(;;) { // ... ever while(!timer_flag) { /* warten auf 1s */ } timer_flag = 0; t1s++; if(t1s >8000) { t1s = 1; if(bit_is_clear(PORTC, PINC0)){ sbi(PORTC, 0); s=s+1; if(s==1){ s=0; sbi(PORTD, 5); } cbi(PORTC, 1); sbi(PORTC, 2); cbi(PORTC, 3); cbi(PORTC, 4); sbi(PORTC, 5); cbi(PORTC, 6); sbi(PORTC, 7); } else { cbi(PORTC, 0); sbi(PORTC, 3); cbi(PORTC, 2); cbi(PORTD, 5); sbi(PORTC, 1); sbi(PORTC, 4); cbi(PORTC, 5); sbi(PORTC, 6); cbi(PORTC, 7); } } } // for(;;) return 0; } /* eof */






Zitieren

Lesezeichen