UART Frame
UART 관련 register 1
1. Baud rate 설정
2. UART 통신 규격 설정
3. UART_Init
void UART_Init(int baud){ // Set baud rate unsigned int ubrr = 16000000/16/baud - 1; UBRR0H = (unsigned char) (ubrr>>8); UBRR0L = (unsigned char) ubrr; // Enable receiver and transmitter UCSR0B = _BV(RXEN0) | _BV(TXEN0); // Set frame format : 8 data, 2 stop bit UCSR0C = _BV(USBS0) | _BV(UCSZ01) | _BV(UCSZ00); }
참고자료
- Atmel AVR 328p datasheet - 20. USART0
- 이승호 외 3명, "핵심포인트를 꽉 집어주는 AVR ATmega128 완전정복", 표 1.18.2