Fix serial baudrate setting on the Arduino Uno
authorarighi <arighi@38d2e660-2303-0410-9eaa-f027e97ec537>
Mon, 14 Mar 2011 14:01:27 +0000 (14:01 +0000)
committerarighi <arighi@38d2e660-2303-0410-9eaa-f027e97ec537>
Mon, 14 Mar 2011 14:01:27 +0000 (14:01 +0000)
The Arduino bootloader toggles the U2X0 bit in UCSR0A and leaves it set,
causing the baudrate to be doubled.

Signed-off-by: Bernie Innocenti <bernie@codewiz.org>
git-svn-id: https://src.develer.com/svnoss/bertos/trunk@4770 38d2e660-2303-0410-9eaa-f027e97ec537

bertos/cpu/avr/drv/kdebug_avr.c
bertos/cpu/avr/drv/ser_avr.c

index 8fa1a4bff62c5fdd27366d267248447661a01989..e5718c90545fbac6fe8a15c803dcdb1fe283cea8 100644 (file)
@@ -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
index 7f8cf932c2bd8f6cbd8d219d19988aa37a02cccc..7bfc8d2c3aec4ded98cb4e7e1d1b76a368e4ae41 100644 (file)
         * - 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