Cactus Technologies Limited
Suite C, 15/F, Capital Trade Center
62 Tsun Yip Street, Kwun Tong
Kowloon, Hong Kong
Tel: +852-2797-2277
Cactus USA
3112 Windsor Road
Suite A356
Austin, Texas 78703
Tel: +512-775-0746
Cactus-Tech.com
An Introduction To SD Card Interface
White Paper CTWP009
CTWP009: An Introduction to SD Card Interface
Cactus Technologies
®
1
The Secure Digital Card (SD Card, for short) was originally introduced to address the need for
reliable data storage in a small form factor for consumer hand-held and portable electronics, such
as cellphones, digital cameras, etc. Recently, there has been increasing interest to adopt the SD Card
for usage in industrial environments also.
Traditionally, the storage interface for industrial applications has been ATA, either in the form of
2.5” drives or via the TrueIDE mode in PC Card, CF Card or DOM. The SD interface, however, is quite
dierent from ATA. This application note is intended to help those who are new to the SD interface
to better understand it's features and usage.
Introduction
01.0
The ocial SD Specications is controlled by the SD Card Association (www.sdcard.org). This ocial
spec. is available only to SD Card Association members. However, the SD Card Association does make
available, for free, a simplied version of the physical layer spec., which is useful to help potential
end users to design in the SD Card in their systems. Anyone who is looking to use the SD Card in their
design should download this document, as it contains valuable information on the physical interface
and command protocols.
Specications
02.0
Just like the CF Card or PC Card, the SD Card contains an internal controller that handles all internal
ash memory operations. The data transfer between the host and the card is done in clock serial
mode, in 512 byte blocks. Currently, the dened le system is FAT12/16 for cards that are 2GByte or
less in capacity, and FAT32 for cards that are 4GByte or more.
The Basics
03.0
Unlike the CF or PC Card, SD Cards do not use pins for contacts.
Instead, the card has 9 contact pads as shown in the picture to the
left.
Note the particularity with pad 9 placement and dierent width
for pad 8. This is due to legacy compatibility requirements with
MMC Cards.
Pinout
03.1
8. DAT1
7. DAT0/DO
6. Vss2
5. CLK
4. Vcc
3. Vss1
2. CMD/DI
1. DAT3/CS
9. DAT2
CTWP009: An Introduction to SD Card Interface
Cactus Technologies
®
2
Standard SD Cards operate at power supply range of 2.7 -3.3V. Special low voltage version SD Cards
can operate at a power supply level as low as 1.6V. Cactus Technologies SD Cards operate at the
standard voltage range.
Voltage Levels
03.2
There are two bus protocols dened for SD Cards. The default mode is native SD mode but the card
can be congured to use a slower SPI mode. Protocol selection is done during the rst reset command
after power up. The SD Card powers up in SD mode. To switch the card to SPI mode, the CS signal
must be asserted while the host issues a reset command to the card. Once a particular protocol is
congured, it cannot be changed while power is applied. The only way to switch between protocol
modes is to do a power cycle.
Information in the remaining sections are for normal SD mode operation. Dierences between SD
mode and SPI mode are summarized in Section 5.0.
Bus Protocols
03.3
SD Cards operates in clock serial mode with bit widths of 1-4 bits. In SPI mode, the card operates in
1- bit mode only.
Bus Width
03.4
SD Cards operate at two speed modes. The default mode clock speed is 0 -25MHz. A high speed mode
is available at clock speed of 0 -50MHz.
Clock Frequencies
03.5
All SD Cards contain a set of information registers which describe and control the various features
that the cards support. These are similar to the Card Conguration Registers and CIS Structure for
PC and CF Cards (or the Identify Drive structure for IDE drives). The following table is a list of the card
information registers and their descriptions:
Card Registers
03.6
CTWP009: An Introduction to SD Card Interface
Cactus Technologies
®
3
Name
Card Identication Number
Relative Card Address; Used Only in SD Mode
Drive Stage Register; This is optional for controlling the card's output drivers
Card Specic Data; this is similar to CIS or Identify Drive structure
SD Conguration Register
Operation Condition Register
CID
RCA
DSR
CSD
SCR
OCR
Width Description
128
16
16
128
64
32
SD Card protocol consists of an exchange of command and/or response tokens between the host
and the card. Data transfers occurs in packets. A packet consists of a data block and CRC check bits.
Data transfer can occur in single block or multi block mode, similar to ATA RD/WR SECTOR and RD/WR
MULTIPLE commands.
All transmissions on the CMD/DAT pins are done with MSB rst. Commands and responses are sent
on the CMD pin while data transfer is done on the DAT pins.
Protocol Basics
04.0
The format of a command token is as follows:
Response Content
0 0 1
48 -BIT RESPONSE TOKEN FORMAT
Response Content
0 0 1
136-BIT RESPONSE TOKEN FORMAT
Command Token
04.1
CTWP009: An Introduction to SD Card Interface
Cactus Technologies
®
4
This white paper is just a simple introduction to the SD Card interface. For more details on the SD
protocol, command set, responses, register descriptions, etc., we highly encouraged the reader to
download the Simplied SD Card Physical Layer Specications from the SD Card Association website
or obtaining the ocial full specication by signing the LAMS agreement available from the SD Card
Association website.
Further Reading
06.0
There are two types of data packet format. One for normal byte wide data and the other for wide
width data which uses a 512 bit data block. Both types of data packets are protected with CRC16.
For normal 512 byte data transfers, the data is transferred least signicant byte rst but in the
individual byte, the data is transmitted MSB rst.
Data transfer can be done in 1-bit mode (using DAT0 only) or 4 -bit mode (if enabled, using DAT0 3).
When using 4 -bit mode, the byte data is formatted such that bit[7:4] are sent on DAT[3:0] followed by
bit[3:0] on DAT[3:0]. There are detailed diagrams of the formatting in the simplied SD Spec. from the
SD Card Association website.
Data Packet
04.2
While most of the SD Card's operation is the same whether in SD mode or SPI mode, there are a few
dierences that need to be pointed out.
SPI Mode Operation
05.0
SPI mode uses only 1 -bit wide data bus width.
SPI transfers are byte oriented; all commands and data transfers consists of a series of bytes.
Two new response tokens are dene for SPI mode.
If the card encounters an error condition during data read, it will respond with an ERROR token
in SPI mode rather than a timeout as in SD mode.
For block writes in SPI mode, the card returns a data response token after receiving each
data block.
For block writes in SPI mode, the data block is preceded with a Start Block Token.
CRC protection is optional for SPI mode. However, the RESET command is issued while the card
is in SD mode, thus, this command must be issued with a valid CRC eld.
Command class 1, 3 and 9 are not supported in SPI mode. The supported commands for a
specic class are also dierent between SPI and SD modes.
CTWP009: An Introduction to SD Card Interface
Cactus Technologies
®
5
The following are some pictorial representations of data transfer sequences on the SD interface.
Appendix
07.0
Single block read transfer, SD mode
RESPONSE
DATA FROM CARD TO HOSTFROM HOST TO CARD
CMD
DAT
DATA BLOCK CRC
COMMAND
FROM CARD TO HOST
CRC OK RESPONSE AND BUSY FROM CARD TO HOSTDATA FROM HOST TO CARD
STOP COMMAND FROM HOST
CMD
DAT
DATA BLOCK CRC DATA BLOCK CRC DATA BLOCK CRC
RESPONSECOMMANDRESPONSECOMMAND
CRC OK RESPONSE AND BUSY FROM CARD TO HOSTDATA FROM HOST TO CARD
STOP COMMAND
FROM HOST
CMD
DAT
DATA BLOCK CRC DATA BLOCK CRC
RESPONSECOMMANDRESPONSECOMMAND
CMD
DAT
DATA BLOCK CRC BUSY
BUSY BUSY
RESPONSECOMMAND
Multi block read transfer, SD mode
RESPONSE
DATA FROM CARD TO HOSTFROM HOST TO CARD
CMD
DAT
DATA BLOCK CRC
COMMAND
FROM CARD TO HOST
CRC OK RESPONSE AND BUSY FROM CARD TO HOSTDATA FROM HOST TO CARD
STOP COMMAND FROM HOST
CMD
DAT
DATA BLOCK CRC DATA BLOCK CRC DATA BLOCK CRC
RESPONSECOMMANDRESPONSECOMMAND
CRC OK RESPONSE AND BUSY FROM CARD TO HOSTDATA FROM HOST TO CARD
STOP COMMAND
FROM HOST
CMD
DAT
DATA BLOCK CRC DATA BLOCK CRC
RESPONSECOMMANDRESPONSECOMMAND
CMD
DAT
DATA BLOCK CRC BUSY
BUSY BUSY
RESPONSECOMMAND
Single block write transfer, SD mode
RESPONSE
DATA FROM CARD TO HOSTFROM HOST TO CARD
CMD
DAT
DATA BLOCK CRC
COMMAND
FROM CARD TO HOST
CRC OK RESPONSE AND BUSY FROM CARD TO HOSTDATA FROM HOST TO CARD
STOP COMMAND FROM HOST
CMD
DAT
DATA BLOCK CRC DATA BLOCK CRC DATA BLOCK CRC
RESPONSECOMMANDRESPONSECOMMAND
CRC OK RESPONSE AND BUSY FROM CARD TO HOSTDATA FROM HOST TO CARD
STOP COMMAND
FROM HOST
CMD
DAT
DATA BLOCK CRC DATA BLOCK CRC
RESPONSECOMMANDRESPONSECOMMAND
CMD
DAT
DATA BLOCK CRC BUSY
BUSY BUSY
RESPONSECOMMAND
CTWP009: An Introduction to SD Card Interface
Cactus Technologies
®
6
RESPONSE
DATA FROM CARD TO HOSTFROM HOST TO CARD
CMD
DAT
DATA BLOCK CRC
COMMAND
FROM CARD TO HOST
CRC OK RESPONSE AND BUSY FROM CARD TO HOSTDATA FROM HOST TO CARD
STOP COMMAND FROM HOST
CMD
DAT
DATA BLOCK CRC DATA BLOCK CRC DATA BLOCK CRC
RESPONSECOMMANDRESPONSECOMMAND
CRC OK RESPONSE AND BUSY FROM CARD TO HOSTDATA FROM HOST TO CARD
STOP COMMAND
FROM HOST
CMD
DAT
DATA BLOCK CRC DATA BLOCK CRC
RESPONSECOMMANDRESPONSECOMMAND
CMD
DAT
DATA BLOCK CRC BUSY
BUSY BUSY
RESPONSECOMMAND
Multi block write transfer, SD mode
DATA FROM CARD TO HOSTFROM HOST TO CARD
SDI
SDO
FROM CARD TO HOST
COMMAND
DATA BLOCKRESPONSE CRC
ERROR TOKEN FROM CARD TO HOST
SDI
SDO
COMMAND
DATA ERRORRESPONSE
CRC OK RESPONSE AND BUSY FROM CARD TO HOSTDATA START TOKEN
SDI
SDO
COMMAND DATA BLOCK
DATA
RESPONSE
BUSYRESPONSE
STOP COMMAND FROM HOST TO CARD
SDI
SDO
COMMAND COMMAND
RESPONSE RESPONSEDATA BLOCK CRC DATA BLOCK CRC
Single block read, SPI mode
DATA FROM CARD TO HOSTFROM HOST TO CARD
SDI
SDO
FROM CARD TO HOST
COMMAND
DATA BLOCKRESPONSE CRC
ERROR TOKEN FROM CARD TO HOST
SDI
SDO
COMMAND
DATA ERRORRESPONSE
CRC OK RESPONSE AND BUSY FROM CARD TO HOSTDATA START TOKEN
SDI
SDO
COMMAND DATA BLOCK
DATA
RESPONSE
BUSYRESPONSE
STOP COMMAND FROM HOST TO CARD
SDI
SDO
COMMAND COMMAND
RESPONSE RESPONSEDATA BLOCK CRC DATA BLOCK CRC
Multiple block read, SPI mode
CTWP009: An Introduction to SD Card Interface
Cactus Technologies
®
7
Block read error response, SPI mode
DATA FROM CARD TO HOSTFROM HOST TO CARD
SDI
SDO
FROM CARD TO HOST
COMMAND
DATA BLOCKRESPONSE CRC
ERROR TOKEN FROM CARD TO HOST
SDI
SDO
COMMAND
DATA ERRORRESPONSE
CRC OK RESPONSE AND BUSY FROM CARD TO HOSTDATA START TOKEN
SDI
SDO
COMMAND DATA BLOCK
DATA
RESPONSE
BUSYRESPONSE
STOP COMMAND FROM HOST TO CARD
SDI
SDO
COMMAND COMMAND
RESPONSE RESPONSEDATA BLOCK CRC DATA BLOCK CRC
Single block write, SPI mode
DATA FROM CARD TO HOSTFROM HOST TO CARD
SDI
SDO
FROM CARD TO HOST
COMMAND
DATA BLOCKRESPONSE CRC
ERROR TOKEN FROM CARD TO HOST
SDI
SDO
COMMAND
DATA ERRORRESPONSE
CRC OK RESPONSE AND BUSY FROM CARD TO HOSTDATA START TOKEN
SDI
SDO
COMMAND DATA BLOCK
DATA
RESPONSE
BUSYRESPONSE
STOP COMMAND FROM HOST TO CARD
SDI
SDO
COMMAND COMMAND
RESPONSE RESPONSEDATA BLOCK CRC DATA BLOCK CRC
Multiple block write, SPI mode
CRC OK RESPONSE AND BUSY FROM CARD TO HOSTDATA START TOKEN
SDI
SDO
DATA STOP TOKEN
COMMAND DATA BLOCK DATA BLOCK
DATA
RESPONSE
BUSY
DATA
RESPONSE
BUSYRESPONSE
CTWP009: An Introduction to SD Card Interface
Cactus Technologies
®
8
If you would like any additional information regarding data contained in this white paper feel free to
contact a Cactus representative:
Asia/Pac RIM [email protected]
Support Information
08.0