diff options
author | David A. Mellis <d.mellis@arduino.cc> | 2012-08-30 08:47:35 -0400 |
---|---|---|
committer | David A. Mellis <d.mellis@arduino.cc> | 2012-08-30 08:47:35 -0400 |
commit | 5ca747e312e70aa87b6056c15f6dae41c2f0f20c (patch) | |
tree | 5a01c52ea5890c30c103f0f935347dc5edbed2ec /cores/arduino/HardwareSerial.cpp | |
parent | 1650169f5d06231bc67bd5cffc484775b34f38c6 (diff) |
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.)
Diffstat (limited to 'cores/arduino/HardwareSerial.cpp')
-rw-r--r-- | cores/arduino/HardwareSerial.cpp | 10 |
1 files changed, 5 insertions, 5 deletions
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); |