Subversion Repositories Projects

Rev

Go to most recent revision | Blame | Last modification | View Log | RSS feed


#include <avr/io.h>
#include <avr/interrupt.h>
#include "main.h"
#include "timer.h"

volatile uint8_t timer;
volatile uint8_t counter, counter2;
volatile uint8_t key;
volatile uint8_t rs232_timer;


ISR(SIG_OUTPUT_COMPARE0)                                                // Timer-Interrupt (100 Hz)
{
        if (counter > 0)
                counter --;
        else
        {
                counter = 10;
                key = (~PINA >> 4) & 0x0F;
                counter2 ++;
        }
       
        if (timer > 0)
                timer --;
               
        if (rs232_timer > 0)
                rs232_timer --;
       
}

void timer_init (void)
{
        TCCR0 = (1<<CS02)|(1<<CS00)|(1<<WGM01); // Prescaler 1024
        OCR0 = 72;                                                                      // Interrupt 100Hz für 7,372800 MHz-Quarz
        TIMSK |= (1<<OCIE0);                                            // Interrupt freigeben für OCR
}