main
Line | |
---|
1 | #include <avr/io.h>
|
---|
2 | #include <avr/interrupt.h>
|
---|
3 | #include <avr/wdt.h>
|
---|
4 | #include <avr/pgmspace.h>
|
---|
5 | #include <util/delay.h>
|
---|
6 |
|
---|
7 | #include <string.h>
|
---|
8 | #include <stdbool.h>
|
---|
9 |
|
---|
10 | #ifdef __AVR_ATmega48P__
|
---|
11 | #define TIFR TIFR0
|
---|
12 | #endif
|
---|
13 |
|
---|
14 | int main() {
|
---|
15 | wdt_enable(WDTO_2S);
|
---|
16 | // configure timer 0 for a rate of 16M/(256 * 256) = ~244Hz
|
---|
17 | TCCR0A = 0; // timer 0 prescaler: 256
|
---|
18 | TCCR0B = 4;
|
---|
19 |
|
---|
20 | //debug LED - output
|
---|
21 | DDRD |= 255;
|
---|
22 |
|
---|
23 | PORTD = 0xAA;
|
---|
24 |
|
---|
25 | while(1) {
|
---|
26 | wdt_reset();
|
---|
27 |
|
---|
28 |
|
---|
29 | // check timer if we need periodic reports
|
---|
30 | if (TIFR & (1 << TOV0)) {
|
---|
31 | TIFR = (1 << TOV0); // reset flag
|
---|
32 | PORTD++;
|
---|
33 | }
|
---|
34 | }
|
---|
35 |
|
---|
36 | return 0;
|
---|
37 | }
|
---|
38 |
|
---|
Note:
See
TracBrowser
for help on using the repository browser.