source: firmware/FSC/src/timer.c@ 15765

Last change on this file since 15765 was 10674, checked in by neise, 14 years ago
ethernet with user interface test
File size: 552 bytes
Line 
1#include "typedefs.h"
2#include <avr/interrupt.h>
3
4
5 volatile U16 milisec = 0;
6 volatile U32 sec = 0;
7
8void timer_init() {
9 // TIMER2 is used as local clock:
10 // configure timer 2
11 TCCR2 = (1<<WGM21); // CTC Modus
12 TCCR2 |= (1<<CS21) | (1<<CS20); // Prescaler 64 --> counts up every 8us
13 OCR2 = 125-1; // --> output compare interrupt occurs every 125 x 8us = 1ms
14 // Compare Interrupt erlauben
15 TIMSK |= (1<<OCIE2);
16
17}
18
19ISR (TIMER2_COMP_vect)
20{
21 if (milisec < 999)
22 ++milisec;
23 else {
24 milisec = 0;
25 sec++;
26 }
27
28}
Note: See TracBrowser for help on using the repository browser.