leo25 / arduino

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

Hardware Serial doesn't work at 300 baud (overflows UBRR) #522

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Setup Serial.begin(300)
2. Loop - read any bytes in, echo them back
3. Observe results in serial monitor

What is the expected output? What do you see instead?
sent: abcdefghijklmnopqrstuvwxyz
receive: }bcfefgníîïlíîï|qrsvuvw~yzíŽ

What version of the Arduino software are you using? On what operating
system?  Which Arduino board are you using?
Arduino 0021/0022 on OSX, Duemilanove, Mega2560, Nano v3.0, Seeeduino Mega & 
RS-232 AVR328

Please provide any additional information below.
The bug is fairly well documented on 
http://arduino.cc/forum/index.php/topic,57174.0.html

Original issue reported on code.google.com by henry.j....@gmail.com on 12 Apr 2011 at 8:44

GoogleCodeExporter commented 9 years ago
try_again:

  if (use_u2x) {
    *_ucsra = 1 << _u2x;
    baud_setting = (F_CPU / 4 / baud - 1) / 2;
  } else {
    *_ucsra = 0;
    baud_setting = (F_CPU / 8 / baud - 1) / 2;
  }

  if ( (baud_setting > 4095) && use_u2x )
  {
    use_u2x = false;
    goto try_again;
  }

Original comment by dmel...@gmail.com on 14 May 2011 at 4:04

GoogleCodeExporter commented 9 years ago
https://github.com/arduino/Arduino/commit/db64d2fc323219c3487947aa28bee07385c96a
67

Note that this exposes a matching bug in the 8U2 firmware: 
http://code.google.com/p/arduino/issues/detail?id=542

Original comment by dmel...@gmail.com on 14 May 2011 at 4:30