Changeset 6d8c366 in avrstuff for chiptest/main.c
- Timestamp:
- Jul 29, 2014, 10:37:32 PM (10 years ago)
- Branches:
- main
- Children:
- d31c2f5
- Parents:
- cd3a9ac
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
chiptest/main.c
rcd3a9ac r6d8c366 1 #include <usart.h> 2 1 3 #include <avr/io.h> 2 4 #include <avr/interrupt.h> … … 12 14 #define DDRLED DDRB 13 15 #define PORTLED PORTB 14 #define LEDBIT 1 << PB216 #define LEDBIT (1 << PB2) 15 17 16 18 #define BAUD 9600 // Safe value even for low clocks. (used by setbaud.h) … … 23 25 24 26 //debug LED - output 25 DDRLED |= 255; 27 DDRLED |= LEDBIT; 28 PORTLED &= ~LEDBIT; 26 29 27 PORTLED = 0; 28 29 // Serial baudrate - use avrlibc magic to compute the baudrate register 30 // values. 31 #include <util/setbaud.h> 32 UBRRH = UBRRH_VALUE; 33 UBRRL = UBRRL_VALUE; 34 #if USE_2X 35 UCSRA |= (1 << U2X); 36 #else 37 UCSRA &= ~(1 << U2X); 38 #endif 39 40 // Enable the serial port. 41 UCSRB = (1<<RXEN) |(1<<TXEN); 42 UCSRC = (1 << UCSZ1) | (1 << UCSZ0); 30 USARTInit(); 43 31 44 32 // Let's rock! … … 55 43 { 56 44 PORTLED ^= LEDBIT; // Toggle the LED 57 U DR = 'H'; // Send a byte to the UART45 USARTWriteChar('H'); // Send a byte to the UART 58 46 } 59 47 }
Note:
See TracChangeset
for help on using the changeset viewer.