Latency of Serial.println() with Arduino UNO

As a part of my current experiment, I’m running following piece of code:

The picture below shows the “pinDeviceReadReady (DATA_READY)” indicator value (red) and SPI clock (blue).  There are significant delays after DATA READY indicator is up until the UNO executes SPI transfer.

data_ready_and_SPI_clock_with_serial

This is due to Serial.println() debug prints inserted between SPI transfers.  I’ve not read the Serial.println() implementation, but the delay looks to be ranging from 100 to 150 micro seconds.

The large delay disappeared when I removed the Serial.println() lines.

data_ready_and_SPI_clock_without_serial

However, you still see delay when you close up a little more.

data_ready_and_SPI_clock_closeup

This is possibly caused by digitalRead() for the indicator or invoking SPI.transfer().  I don’t have to remove this delay for this experiment, but may need to do so later.  The delay is about 3 micro seconds.

2 thoughts on “Latency of Serial.println() with Arduino UNO

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.