0

Using a UDOO Quad, I am attempting to push data from the Atmel SAM3X8E (Arduino side) to the Freescale i.MX 6 (Linux side) over the serial port as fast as possible. Currently, I am limited to about 10,000 bytes/second, which is plausible because the serial port is configured to 14,400 bytes (115,200 bits) per second. Does anyone know how I can increase the speed of the serial connection? Alternatively, if there is some other means besides Serial to pass data to the ARM processor, I could use that. My Arduino sketch is below. As it is, the "Unable to write quickly enough" is sent. If two characters are removed from Serial.println("012345678901"), then it passes. I am using the built in Arduino Serial port monitor (Tools -> Serial Monitor).

unsigned long sample_period = 1000; //micro seconds.
unsigned long current_time = 0;

void setup() {
    Serial.begin(115200); //115200 bits per sec, 14400 bytes per sec
    current_time = micros();
}

void loop() {
    int wait_count = 0;

    while(micros() - current_time < sample_period) {
        wait_count++;
    }

    if(wait_count == 0) { 
        Serial.println("Unable to write quickly enough");
    }
    current_time = micros();
    Serial.println("012345678901");
}

Edit: After reading Sendhikumar's comment below, I was more systematic and went through all the frequencies in termios.h. I found that 576000 bits per second is valid, and my new data rate is 56,000 bytes per second. I'd still like more speed if possible. The built in Arduino serial monitor does not support this frequency, so now I am catching the serial data with a custom C++ program (based on www.tldp.org/HOWTO/Serial-Programming-HOWTO/x115.html).

Matthew Grivich
  • 431
  • 3
  • 12
  • 1
    Why don't you increase the baud rate at both ends directly. A value greater than 115200 if supported by both controllers can be used to speed up serial communication. – Sendhilkumar Alalasundaram Apr 12 '16 at 18:16
  • I haven't found a list of data rates supported by the UDOO, and my previous guesses were not successful. After reading your comment, I was more systematic and went though all the values in termios.h and found that 576000 bits/second is a valid setting, any my max data rate is now 56,000 bytes per second. Thanks. – Matthew Grivich Apr 12 '16 at 18:57
  • BTW "Slow" is a relative term, I remember when 2400 baud was fast and expensive. You could use SPI instead of async serial, one chip as a master, one as a slave. SPI has an independent clock wire so the data rate can be higher. Async serial is limited by the fact that the receiver signal needs to be sampled at 8X or 16X the data rate to properly recover the signal. – TomKeddie Apr 13 '16 at 00:40
  • Those are what I refer to as "the bad old days". It looks like SPI is not enabled with the default ubuntu image. It does not appear in the device tree editor and there are some discussions about how to add support by rebuilding the kernel (http://www.udoo.org/forum/threads/enable-spi.2488/). That's a bit beyond the scope of what I'm willing to attempt right now, but if I become desperate for more speed, I'll try it out. – Matthew Grivich Apr 13 '16 at 20:48

0 Answers0