13-20
MCF5249UM
MOTOROLA
FlashMedia Interface
13.4.6
FLASHMEDIA INTERFACE OPERATION IN SECURE DIGITAL (SD) MODE
All interactions to the Secure Digital (SD) card can be broken down in a number of cascaded elementary
operations. There are three elementary operations to the card in SD mode:
Sent command to card
Read data from card (one or more packets)
Write data to card (one or more packets)
13.4.6.1
Sent Command To Card
Figure 13-16 Sent Command To Card
The sent-command sequence first sends out a command on the CMD line, then receives a card response
on the same CMD line. After receiving the card response, the host may drive the CMD and DATA lines
depending on the values of the DRIVECMDMASK and DRIVEDATAMASK.
Note: Both lines must be driven if the next operation is sending a write data packet to the
card. The CMD line must be driven, while DATA lines are kept Z when the next
operation is receiving read data from the card. Both CMD and DATA lines are kept
Z when no data follows the command.
While the host is sending data and receiving status from the card, it must look for events on the
SHIFTBUSY2 status bit in the FLASHMEDIASTATUS register. It is also possible to capture these events
using the SHIFTBUSY2RISE and SHIFTBUSY2FALL interrupts.
To exchange data with the card, the host must write the FLASHMEDIADATA2 register when TX2EMPTY
interrupt is set, or read FLASHMEDIADATA2 when RCV2FULL is set. This can be done by using
interrupts, by polling FLASHMEDIAINTSTAT, or by using a DMA channel on FLASHMEDIADATA2.
A number of bits/bytes/longwords corresponding with CMDBITCOUNT must be written to
FLASHMEDIADATA2 during the command transmission. All words, except the first word, contain 32 bits of
data. The first word contains the remainder. The data in the first word is left-justified. No CRC logic is
present in hardware, so CRC must be inserted by software.
ZZ
write
FLASHMEDIACMD2 =
0x60000 +
cmdBitCount +
driveCmdMask +
driveDataMask
write one or more
times to
FLASHMEDIADATA2
ZZ
SE
Host command
cmdBitCount
SE
Card Response
rspBitCount
PP
P
Card driving bus
PZ PZ PZ PZ Z
Z
PZ PZ PZ PZ Z
note 1
note 2
write
FLASHMEDIACMD2 =
rspBitCount +
driveCmdMask +
driveDataMask
read one or more
times from
FLASHMEDIADATA2
write
FLASHMEDIACMD2 = 0
Note 1: If driveCmdMask = 0x40000, CMD line is driven P after receiving card response
If driveCmdMask = 0, CMD line is not driven (Z) after receiving card response
Note 2: If driveDataMask = 0x80000, DATA lines are driven P after receiving CMD response.
If driveDataMask = 0, DATA lines are not driven (Z) after receiving CMD response.
Note 3:To stop host driving P on cmd or data lines, write FLASHMEDIACMD2 with driveDataMask or driveCmdMask 0
CMD line
DATA lines
shift_busy2
bitcounter2
Note 4: Host interface will stop SCLK_OUT clock when needed to prevent transmit underrun or receive overrun. (not shown)
F
re
e
sc
a
le
S
e
m
ic
o
n
d
u
c
to
r,
I
Freescale Semiconductor, Inc.
For More Information On This Product,
Go to: www.freescale.com
n
c
..
.