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 | int main() {
|
---|
11 | wdt_enable(WDTO_2S);
|
---|
12 | // configure timer 0 for a rate of 16M/(256 * 256) = ~244Hz
|
---|
13 | TCCR0A = 0; // timer 0 prescaler: 256
|
---|
14 | TCCR0B = 4;
|
---|
15 |
|
---|
16 | //debug LED - output
|
---|
17 | DDRD |= 255;
|
---|
18 |
|
---|
19 | PORTD = 0;
|
---|
20 |
|
---|
21 | // Serial PORT
|
---|
22 | UBRRH = 10;
|
---|
23 | UBRRL = 0;
|
---|
24 |
|
---|
25 | UCSRB = (1<<RXEN) |(1<<TXEN);
|
---|
26 |
|
---|
27 | while(1) {
|
---|
28 | wdt_reset();
|
---|
29 |
|
---|
30 |
|
---|
31 | // check timer if we need periodic reports
|
---|
32 | if (TIFR & (1 << TOV0)) {
|
---|
33 | TIFR = (1 << TOV0); // reset flag
|
---|
34 | PORTD ^= (1<<PD6);
|
---|
35 |
|
---|
36 | UDR = 'H';
|
---|
37 | }
|
---|
38 | }
|
---|
39 |
|
---|
40 | return 0;
|
---|
41 | }
|
---|
42 |
|
---|
Note:
See
TracBrowser
for help on using the repository browser.