//============================================================================= // Titel : LED Flash über Interrupt //============================================================================= // This source file is subject of the GNU general public license 2, // that is available at the world-wide-web at // http://www.gnu.org/licenses/gpl.txt //----------------------------------------------------------------------------- // Prozessor : ATTiny2313 8.000.000Hz // Sprache : C // Datum : 12.02.2011 // Autor : // history : 2011-02-12 V1.0 Beginn //----------------------------------------------------------------------------- #include #include #include #include #include #include #ifndef TAKT #define TAKT 8000000UL #endif /////////////////////////////////////////////////////////////////////////////// // GLOBALE VARIABLEN volatile uint8_t tick_counter; volatile uint8_t ticker; /////////////////////////////////////////////////////////////////////////////// // Timer0 overflow Interrupt // hier wird der Hauptschleife ein neuer Timerinterrupt signalisiert //----------------------------------------------------------------------------- ISR(TIMER0_OVF_vect) { ticker = ++tick_counter; // PORTB = ticker; } /////////////////////////////////////////////////////////////////////////////// // // BEGIN MAIN // //============================================================================= int main(void) { /////////////////////////////////////////////////////////////////////////////// // // PORT Definition: // //============================================================================= // // Funktion : PORT B - Ausgaenge //----------------------------------------------------------------------------- PORTB = 0x00; // Ausgaenge an Weichen und Signalen DDRB = 0xFF; // PortB ALLES als Ausgang /////////////////////////////////////////////////////////////////////////////// // // Timer0 konfigurieren // //============================================================================= TCCR0A = (0 << COM0A1) // compare match A | (0 << COM0A0) | (0 << COM0B1) // compare match B | (0 << COM0B0) | 0 | 0 | (0 << WGM01) | (0 << WGM00); // Timer0 Mode 2 = CTC - Int on compare A //------------------------------------------------------------------------- TCCR0B = (0 << FOC0A) // CS02 CS01 CS00 Funktion | (0 << FOC0B) //--------------------------------------------- | 0 // 0 0 0 STOP Timer/Counter | 0 // 0 0 1 CPU-Takt | (0 << WGM02) // 0 1 0 CPU-Takt/8 | (1 << CS02) // 0 1 1 CPU-Takt/64 | (0 << CS01) // 1 0 0 CPU-Takt/256 | (1 << CS00); // 1 0 1 CPU-Takt/1024 // 1 1 0 ext.Pin T0,Flanke neg // 1 1 1 ext.Pin T0,Flanke pos //------------------------------------------------------------------------- TIMSK = (0<