]> git.tdb.fi Git - model-railway-devices.git/commitdiff
Set UCSR0A in serial_init
authorMikko Rasa <tdb@tdb.fi>
Sat, 18 May 2013 15:55:21 +0000 (18:55 +0300)
committerMikko Rasa <tdb@tdb.fi>
Sat, 18 May 2013 15:55:21 +0000 (18:55 +0300)
It contains the U2X0 bit, which must be cleared to get the desired
bitrate.  Some versions of the Arduino bootloader appear to leave it
set.

common/serial.c

index 2bf6901836064ece4517047dcb8d94f70838d99f..a5e5cae98ecae7dd5b7a9db2f1a94aeae70f0d35 100644 (file)
@@ -11,6 +11,7 @@ void serial_init(uint16_t baud)
        baud = (F_CPU/16+baud/2)/baud-1;
        UBRR0H = baud>>8;
        UBRR0L = baud;
+       UCSR0A = 0;
        UCSR0C = BIT(UCSZ00) | BIT(UCSZ01);  // 8N1
        UCSR0B = BIT(RXEN0) | BIT(TXEN0) | BIT(RXCIE0);
 }