Latency of Serial.println() with Arduino UNO
As a part of my current experiment, I’m running following piece of code:
if (digitalRead(pinDeviceReadReady) == HIGH) { Serial.println("DATA READY"); spiSend(0x20); // command "read request" readBuffer.deviceId = spiReceive(); Serial.println(readBuffer.deviceId); readBuffer.wireId = spiReceive(); Serial.println(readBuffer.wireId); readBuffer.length = spiReceive(); Serial.println(readBuffer.length); for (int i = 0; i <= readBuffer.length; ++i) { readBuffer.data[i] = spiReceive(); Serial.println(readBuffer.data[i]); } } where inline void spiSend(uint8_t data) { // wait for device ready to write while (digitalRead(pinDeviceWriteReady) == LOW); SPI.transfer(data); } inline uint8_t spiReceive() { while (digitalRead(pinDeviceReadReady) == LOW); uint8_t data = SPI.transfer(0); return data; }