main
Last change
on this file since 4fbae10 was 0be09ca, checked in by Adrien Destugues <pulkomandy@…>, 13 years ago |
- Fix schematic for µSerial : add "local handshake" to make some PCs happy
- Some improvements to the test code.
git-svn-id: svn://pulkomandy.tk/avrstuff@42 c6672c3c-f6b6-47f9-9001-1fd6b12fecbe
|
-
Property mode
set to
100644
|
File size:
730 bytes
|
Rev | Line | |
---|
[98713b5] | 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 |
|
---|
[8f4b118] | 19 | PORTD = 0;
|
---|
| 20 |
|
---|
| 21 | // Serial PORT
|
---|
[0be09ca] | 22 | UBRRH = 0;
|
---|
| 23 | UBRRL = 10;
|
---|
[8f4b118] | 24 |
|
---|
| 25 | UCSRB = (1<<RXEN) |(1<<TXEN);
|
---|
[0be09ca] | 26 | UCSRC = (1 << UCSZ1) | (1 << UCSZ0);
|
---|
[98713b5] | 27 |
|
---|
| 28 | while(1) {
|
---|
| 29 | wdt_reset();
|
---|
| 30 |
|
---|
| 31 |
|
---|
| 32 | // check timer if we need periodic reports
|
---|
| 33 | if (TIFR & (1 << TOV0)) {
|
---|
| 34 | TIFR = (1 << TOV0); // reset flag
|
---|
[8f4b118] | 35 | PORTD ^= (1<<PD6);
|
---|
| 36 |
|
---|
| 37 | UDR = 'H';
|
---|
[98713b5] | 38 | }
|
---|
| 39 | }
|
---|
| 40 |
|
---|
| 41 | return 0;
|
---|
| 42 | }
|
---|
| 43 |
|
---|
Note:
See
TracBrowser
for help on using the repository browser.