source: avrstuff/test_2313_muserial/main.c@ f51aacc

main
Last change on this file since f51aacc was f51aacc, checked in by Adrien Destugues <pulkomandy@…>, 10 years ago

Convert muserial test to common.mk.

git-svn-id: svn://pulkomandy.tk/avrstuff@104 c6672c3c-f6b6-47f9-9001-1fd6b12fecbe

  • Property mode set to 100644
File size: 875 bytes
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
16int 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.