Pages: [1]   Go Down
Author Topic: Set Arduino serial baud rate above 115200 ->230400, 256000,307200,614400  (Read 8301 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 85
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello,

I would like to increase the speed of the serial port above 115200 baud. I have tried the test below. Usb cable from pc connected to arduino 328p. Tried to view results in br@y terminal 1.9b. It did not print anything(if I try same test with 115200, it works fine). Do I have to modify hardwareserial.cpp in order to achieve these higher speeds?

Thanks,

-ren


void setup()                   
{
  Serial.begin(256000);         
 
  Serial.println("Hello world!"); 
}

void loop()                     
{
                               
}
Logged

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 227
Posts: 14048
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

you have to use tuned speeds that fit nicely with the 16MHz clock. 

got succesfull transfers at 230400, 345600 and 500000
see older thread - http://arduino.cc/forum/index.php/topic,61381.msg444421.html#msg444421

Logged

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Global Moderator
Dallas
Online Online
Shannon Member
*****
Karma: 212
Posts: 13085
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset


I typically use 250K and have had no problems.
Logged

0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 85
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

robtillaart,

Yes, I see that now.  I did get 230400 to work, had data bits set incorrectly to 7 in the terminal. If I keep the speeds listed on the mega 328 datasheet for 16mhz, it works well, as you stated. I tried pushing it to 2mbs using the code you posted(see below). I didn't do any error checking, but it seemed to work fine. By the way, if anybody is interested, the speeds listed in the datasheet for 16mhz are 230400/250000/500000/1000000. Also it doesn't have it listed, but indicates 0% error up to 2mbs using u2xn=1.

Thanks for the help!

-ren

void setup()
{
  
  Serial.begin(2000000);   // !! 115200, 230400, 345600,   460800 X
  //delay(1000);
  //Serial.println("Hello World");
}

void loop()
{
  
  unsigned long t1 = millis();
  for (long i=0; i< 10000; i++)
  {
   Serial.println("12345678");  // 10 bytes incl \r\n  
  }
  Serial.println(millis() - t1);
}
Logged

Central MN, USA
Offline Offline
Tesla Member
***
Karma: 76
Posts: 7307
Phi_prompt, phi_interfaces, phi-2 shields, phi-panels
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm interested in this topic as well. Can I ask all that asked/replied what USB/TTL adapter you are using? I have FTDI and 8u2 with arduinos and a moderndevice.com usb bub II.
Logged


Global Moderator
Dallas
Online Online
Shannon Member
*****
Karma: 212
Posts: 13085
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Can I ask all that asked/replied what USB/TTL adapter you are using?

Arduino Uno.  Pololu USB AVR Programmer.
Logged

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 227
Posts: 14048
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

uno & 2009, std usb
Logged

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 85
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

arduino duemilanove std usb cable
Logged

Pittsburgh, PA, USA
Offline Offline
Faraday Member
**
Karma: 99
Posts: 4837
I learn a bit every time I visit the forum.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

How does this compare to SPI?

One reason is that every mobo I have owned for over 10 years now has SPI.
Logged

I find it harder to express logic in English than in Code.
Sometimes an example says more than many times as many words.

Central MN, USA
Offline Offline
Tesla Member
***
Karma: 76
Posts: 7307
Phi_prompt, phi_interfaces, phi-2 shields, phi-panels
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

arduino duemilanove std usb cable

Thanks for the good news. I'll try this also. It's (500000) a lot better than 115200 with almost 8% error because of frequency mismatch.
Logged


Global Moderator
Dallas
Online Online
Shannon Member
*****
Karma: 212
Posts: 13085
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

How does this compare to SPI?

SPI requires two lines (but usually uses three or four) instead of the one (but usually uses two) required for serial connections.  Clocking is always performed by the master; neither the master nor the slave needs a calibrated clock.  Serial requires both sides to have moderately calibrated clocks.  The maximum bitrate of SPI is F_CPU / 2 (8 Mb/s).  For asynchronous serial communications the maximum bitrate is F_CPU / 8 (2 Mb/s).

Quote
One reason is that every mobo I have owned for over 10 years now has SPI.

I wonder if that could be used for programming.
Logged

Pittsburgh, PA, USA
Offline Offline
Faraday Member
**
Karma: 99
Posts: 4837
I learn a bit every time I visit the forum.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

It seems that they are there to at least recover bricked bios'es.
I also see some articles on Linux SPI drivers but wow, not simple!



Logged

I find it harder to express logic in English than in Code.
Sometimes an example says more than many times as many words.

Pages: [1]   Go Up
Jump to: