|
emFile supports the use of MultiMedia & SecureDigital (SD) cards. Two optional
generic drivers for MultiMedia & SecureDigital (SD) cards are available.
MultiMedia & SecureDigital (SD) cards can be accessed though two different modes:
- SPI MODE
- MMC/SD card mode.
For both modes drivers are available.
To use one of these drivers, you need to configure the MMC driver and provide basic
I/O functions for accessing your card reader hardware.
This section describes how to enable one of these drivers and all hardware access
functions required by emFile's for either the MultiMedia & SD card SPI mode or Multi-
Media & SD card mode driver.
Supported hardware
MultiMedia Cards (MMC) and SecureDigital Cards (SD card) are small size factored
mass storage devices.
|
The main design goal of these devices are to provide a very low cost
mass storage product, implemented as a card with a simple controlling unit, and a compact, easy-to-implement interface. These
requirements lead to a reduction of the functionality of each card to an absolute minimum.
In order to have a flexible design, MMC and SD cards are designed to be used in different I/O modes:
- MMC/SD card mode
- SPI mode
- Emulated SPI mode, using port pins.
|
The difference between MMC and SD cards are that SD cards can operate with a higher clock frequency. The clock range can be between 0 - 25MHz, whereas MMCs
can only operate up to 20MHz. Additionally the initialization of these cards differs.
They need to be initialized differently, but after initialization they behave the same way.
MMC and SD cards also differ in the count of pins. SD cards have more
pins than MMCs. Depending in which mode they are used the pins are used
or not. Additionally SD cards have a write protect switch, which can be
used to lock the data on the card.
|
In MMC/SD card mode
MultiMedia Cards use a seven pin interface in MultiMedia card mode (Command, Clock, Data and 3x Power lines). In contrast to the MultiMedia cards SD cards
use a 9 pin interface (Command, Clock, 1 or 4 Data and 3 Power lines).
In SPI mode
Both card systems use the same the pin interface. (ChipSelect (CS),
DataIn, DataOut, Clock and 3 Power lines).
|
Pin description for MMC/SD card in Card mode
| 1 |
CD/DAT3 |
Input/Output using push pull drivers |
After power up this line is input with 50 kOhm pull-up. This can be used for card detection. Relevant only for
SD cards, pull-up resistor is disabled after initialization procedure for using this line as DATA3 line for data transfer.
|
| 2 |
CMD |
Push Pull |
This is a bi-directional line. It is a bidirectional command channel used for card
initialization and data transfer commands. The CMD signal has two operation modes: open-drain for initialization mode and push-pull for fast command transfer.
Commands are sent from the MultiMediaCard bus master (card host controller) to the card and responses from the cards to the host.
|
| 3 |
Vss |
Power supply |
Supply voltage ground. |
| 4 |
Vdd |
Power supply |
Supply voltage. |
| 5 |
CLK |
Input |
With each cycle of this signal an one bit transfer on the command and data lines is done. The frequency may vary between zero and the maximum clock frequency. |
| 6 |
Vss2 |
Power supply |
Supply voltage ground. |
| 7 |
DAT[0] |
Input/Output using push pull driver |
DAT is a bidirectional data channel. The DAT signal operates in
push-pull mode. Only one card or the host is driving this signal at
a time. Relevant only for SD cards: On data transfer, this line is
DATA 0. |
| 8 |
DAT[1] |
Input/Output using push pull drivers |
On MMC card this line does not exist. Relevant only for SD cards:
On data transfer, this line is DATA 1. |
| 9 |
DAT[2] |
Input/Output using push pull drivers |
On MMC card this line does not exist. Relevant only for SD cards:
On data transfer, this line is DATA 2. |
Pin description for MMC/SD card in SPI mode
| 1 |
CS |
Input |
Chip Select sets the card active at low level and inactive at high level. |
| 2 |
Data In |
Input |
Data In is seen from the card, therefore data transmitted to the card will be received from this line. |
| 3 |
Vss |
Supply ground |
Supply voltage ground. |
| 4 |
Vdd |
Supply voltage |
Supply voltage. |
| 5 |
SCLK |
Input |
Clock signal must be generated by the target system.
The card is always in slave mode. |
| 6 |
Vss2 |
Supply ground |
Supply voltage ground. |
| 7 |
Data Out |
Output |
Data Out is seen from the card. Data transferred to host will be sent by card from this line. |
| 8 |
Reserved |
Not used |
- |
| 9 |
Reserved |
Not used |
- |
Additional Information
- Data transfer width is 8-bit.
- Data should be output on the falling edge and must remain valid until the next period. Rising edge means data is sampled (i.e. read).
- Bit order requires most significant bit (MSB) to be sent out first.
- Data polarity is normal, which means a logical "1" is represented with a high level on the data line and a logical "0" is represented with low level.
- MultiMedia & SD cards support different voltage ranges. Initial voltage should be 3.3V.
Power control should be considered when creating designs using the MultiMediaCard
and/or SD Card. The ability to have software power control of the cards makes the
design more flexible and robust. The host will have the ability to turn power to the
card on or off independent of whether the card is inserted or removed. This can help
with card initialization when there is contact bounce during card insertion. The host
waits a specified time after the card is inserted before powering up the card and
starting the initialization process. Also, if the card goes into an unknown state, the
host can cycle the power and start the initialization process again. When card access
is unnecessary, allowing the host to power-down the bus can reduce overall power
consumption.
Theory of operation
The Serial Peripheral Interface (SPI) bus is a very
loose de facto standard for controlling almost any digital electronics
that accepts a clocked serial stream of bits. SPI operates in full duplex
(sending and receiving at the same time).
Fail-safe operation
Unexpected Reset
The data will be preserved.
Power failure
Power failure can be critical: If the card does not have sufficient time to complete a
write operation, data may be lost. Countermeasures: make sure the power supply for
the card drops slowly.
Wear leveling
MMC / SD cards are controlled by an internal controller,
this controller also handles wear leveling. Therefore, the driver does
not need to handle wear leveling.

|