What to watch for!

There are a few things to watch for when interacting with SD cards:

One is that they are strictly 3.3V devices and the power draw when writing to the card can be fairly high, up to 100mA (or more)! That means that you must have a fairly good 3.3V power supply for the card. Secondly you must also have 3.3V logic to interface to the pins. We've found that SD cards are fairly sensitive about the interface pins - the newest cards are edge triggered and require very 'square' transitions - things like resistor dividers and long wires will have a deleterious effect on the transition speed, so keep wires short, and avoid using resistor dividers for the 3.3V logic lines. We suggest instead using level shifters, such as HEF4050, 74LVX245 or 74AHC125 chips.

For the level shifter we use the CD74HC4050 which has a typical propagation delay of ~10ns

Secondly, there are two ways to interface with SD cards - SPI mode and SDIO mode. SDIO mode is faster, but is more complex and as far as we can tell, requires signing non-disclosure documents. For that reason, you will likely never encounter SDIO mode interface code. Instead, every SD card has a 'lower speed' SPI mode that is easy for any microcontroller to use. SPI mode requires four pins (we'll discuss them in detail later) so it's not pin-heavy like some parallel-interface components

SD cards come in two popular flavors - microSD and SD. The interface, code, structure, etc is all the same. The only differences is the size. MicroSD are much much smaller in physical size.

Third, SD cards are 'raw' storage. They're just sectors in a flash chip, there's no structure that you have to use. That means you could format an SD card to be a Linux filesystem, a FAT (DOS) filesystem or a Mac filesystem. You could also not have any filesystem at all! However, 99% of computers, cameras, MP3 players, GPS loggers, etc require FAT16 or FAT32 for the filesystem. The tradeoff here is that for smaller microcontrollers (like the Arduino) the addition of the complex file format handling can take a lot of flash storage and RAM.

This guide was first published on Jul 31, 2013. It was last updated on Mar 13, 2024.

This page (Look out!) was last updated on Jul 24, 2013.

Text editor powered by tinymce.