Subversion Repositories Projects

Compare Revisions

Ignore whitespace Rev 111 → Rev 112

/Transportables_Koptertool/trunk/V-0.1.1/timer.c
0,0 → 1,37
 
#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
}