Close

SD Card success

A project log for RP2040 M.2 Pico

A RPI Pico RP2040 board in a M.2 AE key form factor.

magicwolfiMagicWolfi 01/13/2025 at 02:040 Comments

For whatever reason (which I will find out later) I could not make the SD card work on the SPI1 port of the RPi Pico with (CS=GPIO13, CLK=GPIO10, MOSI=GPIO11, MISO=GPIO12).

So I did some re-wiring and used the standard SPI port with the pin mapping as follows:

#define SD_CS         17
#define SD_DI         16
#define SD_DO         19
#define SD_CLK        18

// uSD card
SPI.setRX(SD_DI);
SPI.setCS(SD_CS);
SPI.setSCK(SD_CLK);
SPI.setTX(SD_DO );

 This approach worked flawlessly and I could do all the file system commands provided by the SD.h library.

A simple speed test did show sufficient performance for basic data logging:

SD Card Speed Test...
Writing to byte.txt...done.
Duration [millisec]: 10377
FileSize [bytes]: 1048576
Write Speed(8bit) [KByte/sec]: 102
Writing to 16bit.txt...done.
Duration [millisec]: 15828
FileSize [bytes]: 2097152
Write Speed(16bit) [KByte/sec]: 136
Writing to 32bit.txt...done.
Duration [millisec]: 28910
FileSize [bytes]: 4194304
Write Speed(32bit) [KByte/sec]: 146
done

The write speed vary for the 8bit test from 97 to 128 KB/sec and for the 16bit test from 120 to 136 KB/sec. The 32bit test is very stable at 146 KB/sec.

Discussions