Serial problems at 115200 baud

Hi,

I originally posted this under Due, but have since had the same problems with a new Uno I bought, so I'm now thinking I'm just having issues that might be inherent with either my approach, or Arduino generally.

The following sketch produces garbage at 115200 but at 9600 it works fine. This is just when running the ports into two (2) PC USB serial ports running a terminal program that have been tested to work fine at 115200 on other serial devices, but when connected together like this on the Due, it doesn't work at 115200. I get correct mirror behaviour of terminal talking to terminal at 9600 baud. The same test at 115200 doesn't work.

I'm using a MAX 3232 to convert the TTL Serial2 signals to RS232 and this is rated at well beyond 115200baud. I can send someone the schematic if required of the TTL to RS232 convertor I'm using if required.

void setup() {
  SerialUSB.begin(115200);
  Serial2.begin(115200);
}

void loop() { 
  if (SerialUSB.available()) {    
    Serial2.write((byte)SerialUSB.read());
  }
   
  if (Serial2.available()) {    
    SerialUSB.write((byte)Serial2.read());
  }
}

I can only assume that some kind of timing or buffer issue, but I'm not sufficiently clear on the details to understand why/what. The odd part is that I can run this next script and the results looks fine on both ports. So this confuses me as issues with the port I thought would result in them failing the test below, in saying that, I'm only transmitting out both UARTs whereas the prior sketch has me receiving and transmitting, so maybe there is an issue related to that!?!??

void setup() {
  SerialUSB.begin(115200);
  Serial2.begin(115200);
}

int c = 0;

void loop() {
  SerialUSB.write('A' + c );
  c++;
  if (c == 26) {
    SerialUSB.println();
  }
  
  Serial2.write('a' + c );
  if (c == 26) {
    Serial2.println();
    c = 0;
  }
}

If I disconnect and reconnect the Serial2 port while it is running, I get synchronisation issues, and get garbage. If I continue to randomly disconnect and connect, sometimes it will re-synch and work fine again. Could this be something???

I was hoping to be able to use the Due or Uno UARTs at 115200 on a logging device I have, but unfortunately I cannot seem to communicate at all with this device using Arduino, and yet I can do this with my PC using serial USB adapters?? I'm going to see if I can reconfigure my logging device to work at a lower baud rate and see if that resolves it - problem is that this type of device ships normally at 115200, and lower baud rates mean less logging / second.

Can't for the life of me figure out why the serial ports on the board are being so stubbon at this 115200 baud rate?

I've started wondering if the serial ports I'm seeing issues with relate to the 16Mhz crystal in both the Uno and Due and how at 115200 buad, it is already at 3.5% error rate, and that for some serial devices, this might be too much to tolerate?

Can you compensate in anyway in software? Is this a board design compromise that would have been easily avoided by using a faster crystal.

Does anyone have any experience with swapping out the 16Mhz crystal for a 14.74Mhz or 18.43Mhz? Is that easy to do, and where is it on the Due?? (my Uno clone looks fairly obvious, accept that there is two of them, so I wonder which one?)

Oohhhh... Just thought of something. I'm connecting a DCE to DCE serial port... neither are DTE and is probably why I'm not getting a connection to the remote device. The 115200bps is probably working when connecting to the PC, as it is a DTE device (connected to a DCE device). I was just using a gender changer/straight through, but now I'm thinking I need to wire it null-modem style.

Does that sound right? Plausible as to why I'm not getting the love?

G

gslender:
I'm connecting a DCE to DCE serial port... neither are DTE and is probably why I'm not getting a connection to the remote device. The 115200bps is probably working when connecting to the PC, as it is a DTE device (connected to a DCE device). I was just using a gender changer/straight through, but now I'm thinking I need to wire it null-modem style.

BTW - my thinking was that it isn't just the wiring of the TX/RX TTL pins, in that I need to swap the wiring to incorporate the swap of CTS/RTS and TXD/RXD - I had thought just swapping over the TTL side would reverse the TX/RX over, but now I'm not so sure it does work like that. Mmmm, I guess building a null modem cable can't hurt to rule that out.

As always, if anyone knows... please chime in.

G

Yup - using a null modem cable (or more accurately wiring something that matched that) fixed my issues. I guess I forgot about the DCE/DTE days and how something that talks to the RS232 port needs to be wired correctly and the TTL lines aren't the same thing. Hopefully this post will help others.

G