Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
111 | mikeljo | 1 | |
2 | #include <avr/io.h> |
||
3 | #include <avr/interrupt.h> |
||
4 | #include "main.h" |
||
5 | #include "timer.h" |
||
6 | |||
7 | volatile uint8_t timer; |
||
8 | volatile uint8_t counter, counter2; |
||
9 | volatile uint8_t key; |
||
10 | volatile uint8_t rs232_timer; |
||
11 | |||
12 | |||
13 | ISR(SIG_OUTPUT_COMPARE0) // Timer-Interrupt (100 Hz) |
||
14 | { |
||
15 | if (counter > 0) |
||
16 | counter --; |
||
17 | else |
||
18 | { |
||
19 | counter = 10; |
||
20 | key = (~PINA >> 4) & 0x0F; |
||
21 | counter2 ++; |
||
22 | } |
||
23 | |||
24 | if (timer > 0) |
||
25 | timer --; |
||
26 | |||
27 | if (rs232_timer > 0) |
||
28 | rs232_timer --; |
||
29 | |||
30 | } |
||
31 | |||
32 | void timer_init (void) |
||
33 | { |
||
34 | TCCR0 = (1<<CS02)|(1<<CS00)|(1<<WGM01); // Prescaler 1024 |
||
35 | OCR0 = 72; // Interrupt 100Hz für 7,372800 MHz-Quarz |
||
36 | TIMSK |= (1<<OCIE0); // Interrupt freigeben für OCR |
||
37 | } |