Does serial BAUD rate impact run speed?

I am working on a project that low loop time is fairly critical. This is arduino code for blinking an RGB strip at a rate matching song for a musical so deaf artists can follow the beat. While looking at something I was playing around with timing (trying to get as tight as possible) and how much serial output commands affect speed and found that when I run the test Timing Test, BAUD rate of the default 9600 gave a loop run time of 18,796 microseconds. A BAUD rate of 115200 gave a loop run time of around 1,516 microseconds. A BAUD rate of 4800 gave a loop run time of 37,608 microseconds

On my actual program Visual BPM, I get about the same numbers, but when I set the BAUD rate really low, at least in this simulator the LED blink rate goes really slow. So, here is what I am wondering:

In regards to code run speed (assuming no purposeful delays being added) when using serial to only send data from the Arduino to the computer,

  1. Does the actual run time of the loop take more time to run when the BAUD rate is low compared to high?
  2. When calling 'Serial.println("");' does the Arduino pause execution to push data onto the serial bus, or does it get buffered and something else sends it?
  3. If it does take more time to run at lower BAUD rates, does removing serial related code when not needed make the Arduino run at speeds equivalent to really high BAUD?

Yes, once the serial buffer is full you have to wait for the bytes to be sent.

No, or, yes

Serial output is buffered and if the buffer is full the print statements block until the buffer can hold all characters again.

of course. but without any serial activity it is always quicker as any possible baud rate.

it is buffered and something awaiting that on other side it will read from someone, and if no one there - it waiting forever to push new data.

Sorry that is wrong. Serial data is pushed out of the serial port as soon as it can. If there is no one at the other end to read it then the data is simply spilled out on the sand, so to speak.

1 Like

I still have a bit bucket where they end up I got at a yard sale back in the 20th century.

a7

2 Likes

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.