Cornell University ECE4760
microSD card reader
Pi Pico rp2040 and rp2350
External memory
PICO RAM is about 260 KB and flash program memory is about 2MB. Pico2 has double the RAM. There is often a need for more storage for audio, video, some simulations, and AI. This page explores ways of connecting external memory to the pico/pico2 in ways that do not use too many i/o resources, in this case a serial SD card. The interface to the card is handled by a very nice FatFs library adapted for SD card from carlk3. Conviently reading and writing data may require several things, including mounting the drive, opening/closing files, and of course read/write commands. I borrowed a command line interface from tinyUSB examples to test the SD card functions.
The SD card is completely handled by FatFs. Compatability with PC formatting seems good.
microSD card on Adafruit #254
The SD card is fast, but as usual, when working on a solderless protoboard, the maximum clock speed
you can use is around 20 MHz (maybe as high as 30 MHz) because of spurous pin capacitance.
The Adafruit carrier board is shown below.
Ii seems that this board works better than many clones and cheaper boards.
Pin connections are:
The hw_config.c code provides the ability to remap the SPI channel and the gpio pins connected to the SPI channel.
Interactive test for FatFs file system
When the system resets, the driver will indicate if the driver did not initialize or the SD card failed to mount.
The serial connection can then be used to issue commands to the file system. In a production system, the interactive interface will probably be replaced by specific code.
It was useful to build a test program that allows a user to fiddle with the file system and test performance.
On a serial terminal you can issue the following commands:
For a binary file contaiing 1000 ints, the write rate ranges from about 17 uSec per uint32,
if the file has to be created, and as low at 2 uSec per uint32 for overwriting an existing file.
Read time is faster.
Code, Project Zip
The project folder includes the FastFs library folder.
Copyright Cornell University August 12, 2025