From 6fb3d7c581d32e0599969bc1842771754168cca1 Mon Sep 17 00:00:00 2001 From: arighi Date: Mon, 14 Mar 2011 14:01:27 +0000 Subject: [PATCH] Fix serial baudrate setting on the Arduino Uno The Arduino bootloader toggles the U2X0 bit in UCSR0A and leaves it set, causing the baudrate to be doubled. Signed-off-by: Bernie Innocenti git-svn-id: https://src.develer.com/svnoss/bertos/trunk@4770 38d2e660-2303-0410-9eaa-f027e97ec537 --- bertos/cpu/avr/drv/kdebug_avr.c | 1 + bertos/cpu/avr/drv/ser_avr.c | 1 + 2 files changed, 2 insertions(+) diff --git a/bertos/cpu/avr/drv/kdebug_avr.c b/bertos/cpu/avr/drv/kdebug_avr.c index 8fa1a4bf..e5718c90 100644 --- a/bertos/cpu/avr/drv/kdebug_avr.c +++ b/bertos/cpu/avr/drv/kdebug_avr.c @@ -355,6 +355,7 @@ INLINE void kdbg_hw_init(void) #if CONFIG_KDEBUG_PORT == 0 UBRR0H = (uint8_t)(period>>8); UBRR0L = (uint8_t)period; + UCSR0A = 0; /* The Arduino Uno bootloader turns on U2X0 */ KDBG_UART0_BUS_INIT; #else #error Only CONFIG_KDEBUG_PORT 0 is supported for this cpu diff --git a/bertos/cpu/avr/drv/ser_avr.c b/bertos/cpu/avr/drv/ser_avr.c index 7f8cf932..7bfc8d2c 100644 --- a/bertos/cpu/avr/drv/ser_avr.c +++ b/bertos/cpu/avr/drv/ser_avr.c @@ -146,6 +146,7 @@ * - Enable only the RX complete interrupt */ #define SER_UART0_BUS_TXINIT do { \ + UCSR0A = 0; /* The Arduino Uno bootloader turns on U2X0 */ \ UCSR0B = BV(BIT_RXCIE0) | BV(BIT_RXEN0) | BV(BIT_TXEN0); \ } while (0) #endif -- 2.34.1