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?