Eralt / arduino

Automatically exported from code.google.com/p/arduino
0 stars 0 forks source link

Serial communications at 57600 apparently broken on Uno #394

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Initialized Serial.begin(57600);
2. Send a string containing several characters from serial monitor.
3. attempt to read (using Serial.read()) on the Arduino.

What is the expected output? What do you see instead?
Expected behavior is that the characters would be received properly.  In fact, 
the first one or two are received OK, and later characters in the string are 
corrupted.  See the referenced forum thread for a sample program.  
(interestingly, traffic in the other direction does not seem to be damaged.)

What version of the Arduino software are you using? On what operating
system?  Which Arduino board are you using?
0021 with Arduino Uno.  Host operating system irrelevant.

Please provide any additional information below.
It looks like this is due to the serial code in the 8u usb/serial AVR using 
opposite algorithms for computer bit rate divisors and modes from the 328 main 
cpu. (perhaps in error, perhaps intentionally for unknown reasons)
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1289177335

Original issue reported on code.google.com by wes...@gmail.com on 9 Nov 2010 at 12:49

GoogleCodeExporter commented 9 years ago
How about this baud rate calculation?  It uses double speed mode everywhere, 
except for 57600 baud on the 16 MHz boards.  This ensures compatibility with 
the 8U2 firmware on the Uno and Mega 2560 (which, in turn, was intended to 
allow people to swap their 328 from a Duemilanove to an Uno).  

  bool use_u2x = true;

#if F_CPU == 16000000UL
  // hardcoded exception for compatibility with the bootloader shipped
  // with the Duemilanove and previous boards and the firmware on the 8U2
  // on the Uno and Mega 2560.
  if (baud == 57600) {
    use_u2x = false;
  }
#endif

Original comment by dmel...@gmail.com on 12 Nov 2010 at 4:15

GoogleCodeExporter commented 9 years ago
https://github.com/arduino/Arduino/commit/66755f9bced2009612052800ef7f1a0b9afde3
c5

Original comment by dmel...@gmail.com on 12 Nov 2010 at 4:32

GoogleCodeExporter commented 9 years ago
With Arduino IDE 022, which definately contains the above ^^ fix. The problem 
still exists.

Test program:

void setup() {
  Serial.begin(57600);
}

void loop() {
  while ( Serial.available( ) > 0 ) {
    byte serialByte = Serial.read();
    Serial.print(serialByte);
  }
}

Like others have experienced - change the speed up to 115200 and everythings 
fine. I seriously doubt this is fixed yet.

Dont get me wrong - the change did seem to do "something". Setting use_u2x = 
false gave like a 30% error rate or about 1 in 3 characters. Compared to a 
higher 50% error rate by leaving use_u2x = true.

Perhaps its a case to dig deeper into the 8u2 firmware, and make more 
significant changes.

Original comment by dreamc...@gmail.com on 28 Feb 2011 at 11:23

GoogleCodeExporter commented 9 years ago
What operating system are you on?  I just tested with Mac OS X 10.6 (and 
Arduino 0022) and the communication was flawless.

Original comment by dmel...@gmail.com on 28 Feb 2011 at 1:20

GoogleCodeExporter commented 9 years ago
Tried this earlier today on Mac OS-X 10.6.6 (Build 10J567). With a brand new 
official Arduino UNO bought from Farnell.com 2 weeks ago. Arduino 022 IDE.

Heres a run from the serial monitor just now:

aababcab,öabcVöab,V–ÿab,V–ÿ

The text input was:
a
ab
abc
abcd
abcde
abcde
abcde

(The above program, Serial monitor at 57600 baud, no line ending).

Original comment by dreamc...@gmail.com on 28 Feb 2011 at 3:48

GoogleCodeExporter commented 9 years ago
That was on an Apple Mac Mini (2007-8). The hardware profiler says:

USB Bus:

  Host Controller Location: Built-in USB
  Host Controller Driver:   AppleUSBUHCI
  PCI Device ID:    0x27c8 
  PCI Revision ID:  0x0002 
  PCI Vendor ID:    0x8086 
  Bus Number:   0x1d 

Arduino Uno:

  Product ID:   0x0001
  Vendor ID:    0x2341
  Version:   0.00
  Serial Number:    64938323131351113171
  Speed:    Up to 12 Mb/sec
  Manufacturer: Arduino (www.arduino.cc)
  Location ID:  0x1d100000
  Current Available (mA):   500
  Current Required (mA):    100

Original comment by dreamc...@gmail.com on 28 Feb 2011 at 3:51

GoogleCodeExporter commented 9 years ago
Perhaps these results could be explained if our Uno boards had different 
firmware(s) programmed onto them?

Original comment by dreamc...@gmail.com on 28 Feb 2011 at 4:01

GoogleCodeExporter commented 9 years ago
Apologies - its my mistake. There was some old firmware in my Sketches/hardware 
folder. Clearly that was overriding the stock 022 IDE. Removed the folder and 
the 57600 baud now working.

Thanks for confirming this.

Original comment by dreamc...@gmail.com on 28 Feb 2011 at 10:02