AN184
AN184REV1 3
1. INTRODUCTION
This application note describes a simple interface
between a Cirrus Logic EP72XX microcontroller
and a MultiMediaCard.
The MultiMediaCard (MMC) is a universal low-
cost data storage and communication media. It is
designed to cover a w ide area of applications such
as electronic toys, organizers, PDAs, cameras,
smart phones, digital recorders, and digital players
(such as MP3).
The MMC communication is based on a 7-pin
serial bus designed to operate in a low voltage
range. A MMC communication protocol is defined
as part of the standard and is referred to as MMC
mode. For compatibility, an alternate
communication protocol (a subset of MMC) is
based on the SPI™ (Serial Peripheral Interface)
standard. This application note will describe a
method to support both modes.
2. BACKGROUND
For digital audio applications such as portable MP3
players, the digital content is typically stored in
NAND Flash memory. The MMC offers an
alternative storage media and has the adva ntage of
being removable and portable. For operation using
the SPI protocol, the host must be able to read data
at a typical MP3 data rate of 128 kilo-bits-per-
second (kbits/s).
For programming the MMC, 128 kbits/s rate is
insufficient to provide short download times. A
typical portable MP3 system may include a USB
port that accepts MP3 data files from a host PC.
Since USB is a relatively fast interface with bit
rates approaching 5 Mbits/s average rate (due to
operating system overhead), the main limitation to
download speed is the speed at which the MMC
can be programmed. First versions of MMC cards
can be programmed at ~1 Mbits/s, or around
125 kbytes/s. Newer generations of MMC cards are
expected to reach 2.5 Mbits/s, or ~400 kbytes/s
The EP72xx mic rocontrol lers have a spe ed-l imite d
SPI port. Though adequate for reading content (at
least up to 128 kbits/s), it is too slow for writing.
However, the high speed of the ARM® processor
allows one to create a “virtual peripheral” to
support both SPI and MMC modes. A software
“bit-bang” method provides the necessary signals
for data and command, while a chip select provides
the clock. Transfer speed using this method
approaches 3 Mbits/s. For future applications, the
SD MMC (secure MMC) bus has added 3 more
data lines so that 4-bits can be transferred per clock
(instead of one). This should eventually improve
download speeds approaching that of traditional
NAND flash.
3. MMC MODE VIRTUAL
PERIPHERAL SOLUTION
Two GPIO pins are used for MMC_Data and
MMC_Command. A spare chip select line is used
for MMC_Clock. Section 3.1, “Sample Code:
MMC Interface Connection” contains sample code
that illustrates a possible connection to the MMC
interface. In this case, GPIO pin PA7 is used for
MMC_Data and PA6 is used for MMC_Command.
A schematic is shown in Figure 1.
To maximize transfer speed, the routine to send
bytes to the MMC card should be written in
assembly language. For illustrative purposes, the
sample code is written in C with in-line assembly.
Note that the code is "unrolled", i.e. it does not use
a loop counter to set the number of bits transmitted
(in this case, one byte or 8 bits). Doing so adds
substantially more overhead. As shown, it takes 23
instructions to execute the main routine. This
routine, when running out of cache, should be able
to burst at 74/23 MHz, or approximately 3 Mbs
(see Figure 2). Using a loop counter will add two
extra instructions per iteration, plus another cycle
for the conditional branch, for a total of 8 * (3 + 2)
= 40 cycles, or about ½ the speed of the unrolled
loop.