I've met this problem that Arduino Due takes more time to complete the serial writing than Mega 2560 or Uno.
Here is the code I'm using to test:
int t1,t2;
void setup() {
Serial.begin(115200);
}
void loop() {
t1=micros();
Serial.println("ABCDEFGHABCDEFGHABCDEFGHABCDEFGHABCDEFGHABCDEFGHABCDEFGH01234567");
t2=micros();
Serial.print("time taken: ");
Serial.println(t2-t1);
delay(500);
}
It takes Arduino Due 5,500 microseconds while it takes Arduino Mega 2560 600 microseconds.
To change the serial buffer size for the Mega, I know the buffer size is defined in the Hardwareserial.h at C:\Arduino\hardware\arduino\avr\cores\arduino
. But I could not find the buffer size definition in the corresponding file for the Arduino Due.
Does anyone know how to make the Arduino Due have a faster serial writing speed? We need to transmit the data wirelessly so we could not use the native port although it's very fast.
Thanks!