From 5ca747e312e70aa87b6056c15f6dae41c2f0f20c Mon Sep 17 00:00:00 2001 From: "David A. Mellis" Date: Thu, 30 Aug 2012 08:47:35 -0400 Subject: Changing setting of the UMSELn bits (for UART mode) and serial config values. Before, the UMSELn1 bit was being to set to 1, putting the UART into a reserved mode. Now, we only set the high (0x80) bit to 1 for the ATmega8, which is needed to access UCSRnC (whose i/o address is shared with UBRRH). Also, no longer bitwise-or the new config with the existing register value, because we're actually configuring all the settings in the register. (We're not using UCPOL, but it's supposed to be 0 in asynchronous mode.) --- cores/arduino/HardwareSerial.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'cores/arduino/HardwareSerial.cpp') diff --git a/cores/arduino/HardwareSerial.cpp b/cores/arduino/HardwareSerial.cpp index e512421..2e64acb 100644 --- a/cores/arduino/HardwareSerial.cpp +++ b/cores/arduino/HardwareSerial.cpp @@ -393,11 +393,11 @@ try_again: *_ubrrh = baud_setting >> 8; *_ubrrl = baud_setting; - //set number of data bits - current_config = *_ubrrh; - current_config = *_ucsrc; - current_config |= config; - *_ucsrc = current_config; + //set the data bits, parity, and stop bits +#if defined(__AVR_ATmega8__) + config |= 0x80; // select UCSRC register (shared with UBRRH) +#endif + *_ucsrc = config; sbi(*_ucsrb, _rxen); sbi(*_ucsrb, _txen); -- cgit v1.2.3-18-g5258