Bill Greiman
Well-known member
It appears that it may be possible to use SPI for the on-board microSD. Is this true?
Unless I can get optimized SDHC transfers to work, SPI may be faster for most users.
Here are some print benchmarks for SDHC and optimized multi-block SPI. I use SPI0 which has a four bytes FIFO so I can't say what the result would be with SPI1.
The test writes 20,000 values to a file using a for loop. Here is the for() and the println statements.
Here are results for SDHC:
Here are results for SPI with optimized multi-block transfers.
SPI is three times faster for large uint32_t numbers. This is because single block writes to modern SD cards are slow.
The optimized SPI version uses multi-block writes so even though there is a single cache block, contiguous writes can use multi-block write.
Unless I can get optimized SDHC transfers to work, SPI may be faster for most users.
Here are some print benchmarks for SDHC and optimized multi-block SPI. I use SPI0 which has a four bytes FIFO so I can't say what the result would be with SPI1.
The test writes 20,000 values to a file using a for loop. Here is the for() and the println statements.
Code:
for (uint16_t i = 0; i < 20000; i++) {
// uint16_t println
file.println(i);
// uint32_t println
file.println(12345678UL + i);
// float println
file.println((float)0.01*i);
Here are results for SDHC:
Test of println(uint16_t)
Time 0.29 sec
File size 128.89 KB
Write 442.92 KB/sec
Test of println(uint32_t)
Time 0.41 sec
File size 200.00 KB
Write 485.44 KB/sec
Test of println(float)
Time 0.48 sec
File size 149.00 KB
Write 311.06 KB/sec
Here are results for SPI with optimized multi-block transfers.
Test of println(uint16_t)
Time 0.13 sec
File size 128.89 KB
Write 991.46 KB/sec
Test of println(uint32_t)
Time 0.15 sec
File size 200.00 KB
Write 1351.35 KB/sec
Test of println(float)
Time 0.26 sec
File size 149.00 KB
Write 577.52 KB/sec
SPI is three times faster for large uint32_t numbers. This is because single block writes to modern SD cards are slow.
The optimized SPI version uses multi-block writes so even though there is a single cache block, contiguous writes can use multi-block write.