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