Arduino Forum

Using Arduino => Project Guidance => Topic started by: renasis on Mar 25, 2012, 09:26 pm

Title: Set Arduino serial baud rate above 115200 ->230400, 256000,307200,614400
Post by: renasis on Mar 25, 2012, 09:26 pm
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()                     
{
                               
}
Title: Re: Set Arduino serial baud rate above 115200 ->230400, 256000,307200,614400
Post by: robtillaart on Mar 25, 2012, 10:42 pm
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

Title: Re: Set Arduino serial baud rate above 115200 ->230400, 256000,307200,614400
Post by: Coding Badly on Mar 25, 2012, 11:05 pm

I typically use 250K and have had no problems.
Title: Re: Set Arduino serial baud rate above 115200 ->230400, 256000,307200,614400
Post by: renasis on Mar 26, 2012, 12:07 am
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);
}
Title: Re: Set Arduino serial baud rate above 115200 ->230400, 256000,307200,614400
Post by: liuzengqiang on Mar 26, 2012, 12:35 am
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.
Title: Re: Set Arduino serial baud rate above 115200 ->230400, 256000,307200,614400
Post by: Coding Badly on Mar 26, 2012, 03:07 am
Can I ask all that asked/replied what USB/TTL adapter you are using?


Arduino Uno.  Pololu USB AVR Programmer.
Title: Re: Set Arduino serial baud rate above 115200 ->230400, 256000,307200,614400
Post by: robtillaart on Mar 26, 2012, 06:52 am
uno & 2009, std usb
Title: Re: Set Arduino serial baud rate above 115200 ->230400, 256000,307200,614400
Post by: renasis on Mar 27, 2012, 01:48 am
arduino duemilanove std usb cable
Title: Re: Set Arduino serial baud rate above 115200 ->230400, 256000,307200,614400
Post by: GoForSmoke on Mar 27, 2012, 02:49 am
How does this compare to SPI?

One reason is that every mobo I have owned for over 10 years now has SPI.
Title: Re: Set Arduino serial baud rate above 115200 ->230400, 256000,307200,614400
Post by: liuzengqiang on Mar 27, 2012, 02:53 am

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.
Title: Re: Set Arduino serial baud rate above 115200 ->230400, 256000,307200,614400
Post by: Coding Badly on Mar 30, 2012, 07:10 am
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.
Title: Re: Set Arduino serial baud rate above 115200 ->230400, 256000,307200,614400
Post by: GoForSmoke on Mar 30, 2012, 10:52 am
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!