I am trying to perform some calculations to determine the serial write timing but something is off from expected
I am using a Teensy 4.0 and writing a char array buffer of 64bytes to an open log (SparkFun OpenLog - DEV-13712 - SparkFun Electronics) and an antenna (Transceiver Telemetry Radio V3 433MHz – Holybro) via Serial port. The Antenna is connected to Serial1 and the Open log is connected to Serial 2
Both the open log and the antenna have a baud rate set to 115200.
So according to my calculations:
a 64 bytes data stream corresponds to 64 * 8 + 64 + 64 bits, each packet is composed of 8bits plus 1 start and 1 stop bit, right? So the time to write 64 bytes at 115200 baud should be approximately 64*10/115200 = 5.555ms for each one
However when I use the following code to measure the time of writing:
long ti = micros(); AntenaSerial.write(&buff, 64); long tf = micros(); AntenaSerial.write(10); //line feed Serial.print(tf-ti); Serial.write('\t'); ti = micros(); SDSerial.write(&buff, 64); tf = micros(); SDSerial.write(10); //line feed Serial.println(tf-ti);
Now the odd part is that, the printing results are
How is this possible? Am I missing something?
Thanks in advance,