Last change
on this file since 19366 was 17632, checked in by dneise, 11 years ago |
whitespace changes, using global register
|
File size:
644 bytes
|
Line | |
---|
1 | #include "application.h"
|
---|
2 | #include <avr/interrupt.h>
|
---|
3 |
|
---|
4 | // We use the global volatile register!
|
---|
5 | // gVolReg.time_sec and
|
---|
6 |
|
---|
7 | void timer_init() {
|
---|
8 | // TIMER2 is used as local clock:
|
---|
9 | // configure timer 2
|
---|
10 | TCCR2 = (1<<WGM21); // CTC Modus
|
---|
11 | TCCR2 |= (1<<CS21) | (1<<CS20); // Prescaler 64 --> counts up every 8us
|
---|
12 | OCR2 = 125-1; // --> output compare interrupt occurs every 125 x 8us = 1ms
|
---|
13 | // Compare Interrupt erlauben
|
---|
14 | TIMSK |= (1<<OCIE2);
|
---|
15 | }
|
---|
16 |
|
---|
17 | ISR (TIMER2_COMP_vect) {
|
---|
18 | if (gVolReg.time_ms < 999)
|
---|
19 | ++gVolReg.time_ms;
|
---|
20 | else {
|
---|
21 | gVolReg.time_ms = 0;
|
---|
22 | gVolReg.time_sec++;
|
---|
23 | }
|
---|
24 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.