I just received a R4 Minima and R4 Wifi. Since I am the author of the SdFat library, I did some performance tests. The results were very disappointing. I hoped the R4 would perform better than the R3 since it has a max SPI clock rate of 24 MHz vs 8 MHz for the R3.
Here are the results:
R3 single byte transfer standard SPI library:
write speed and latency
speed,max,min,avg
KB/Sec,usec,usec,usec
417.64,1244,1216,1219
417.64,1244,1216,1219R4 single bytes transfer standard SPI library:
write speed and latency
speed,max,min,avg
KB/Sec,usec,usec,usec
82.98,7164,5160,6162
82.98,7176,5160,6163R4 array transfer standard SPI library:
write speed and latency
speed,max,min,avg
KB/Sec,usec,usec,usec
429.96,2650,634,1182
430.40,2638,634,1181R3 array transfer with my custom functions:
write speed and latency
speed,max,min,avg
KB/Sec,usec,usec,usec
689.18,760,728,736
689.18,760,728,736
I also tried the SD.h library which is based on a modified 2009 version of SdFat. It also has very poor performance and has no array transfer option.
I then ran the following SPI test program on R3 and R4 with the standard SPI library.
#include "SPI.h"
#define CS_PIN 10
#define SPI_CLOCK 24000000
void send(bool loop) {
uint8_t data[] = {'A', 'B', 'C'};
SPI.beginTransaction(SPISettings(SPI_CLOCK, MSBFIRST, SPI_MODE0));
digitalWrite(CS_PIN, LOW);
if (loop) {
for (size_t i = 0; i < sizeof(data); i++) {
SPI.transfer(data[i]);
}
} else {
SPI.transfer(data, sizeof(data));
}
digitalWrite(CS_PIN, HIGH);
SPI.endTransaction();
}
void setup() {
Serial.begin(9600);
pinMode(CS_PIN, OUTPUT);
digitalWrite(CS_PIN, HIGH);
SPI.begin();
send(true);
send(false);
}
void loop() {
}
Here are results.
Uno R3 byte transfer:
Clock is 8 MHz.
1.75 us/byte or 571 KB/sec
This is what i expected, a fair gap between bytes.
Uno R4 bye transfer:
Clock is 24 MHz.
11.87 us/byte or 84.2 KB/sec
Huge gaps between bytes.
Uno R4 array transfer
Clock is 24 MHz.
2.75 us/byte or 364 KB/sec
Strange clock. The first byte has eight pulses evenly spaced. After the first byte there are seven pulses, a big gap and the final pulse.
I hope Arduino has some fix for the SPI library. This is huge disappointment. The R4 seemed like a great replacement for the R3.
Guess I should post an issue on Github.