Skip to content

Instantly share code, notes, and snippets.

@dagon666
Created October 4, 2013 18:24
Show Gist options
  • Save dagon666/6830358 to your computer and use it in GitHub Desktop.
Save dagon666/6830358 to your computer and use it in GitHub Desktop.
atmega328p usart init 57600 baud
void serial_init() {
power_usart0_enable();
// configure ports double mode
UCSR0A = _BV(U2X0);
// configure the ports speed
UBRR0H = 0x00;
UBRR0L = 34;
// asynchronous, 8N1 mode
UCSR0C |= 0x06;
// rx/tx enable
UCSR0B |= _BV(RXEN0);
UCSR0B |= _BV(TXEN0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment