Chapter 5 – SPI Protocol
Revision 2.2
SD Card Product Manual
© 2004 SanDisk Corporation
5-6
12/08/04
5.9 Clock
Control
The SPI bus clock signal can be used by the SPI host to set the cards to energy-saving
mode or to control the data flow (to avoid under-run or over-run conditions) on the bus.
The host is allowed to change the clock frequency or shut it down.
There are a few restrictions the SPI host must follow:
•
The bus frequency can be changed at any time (under the restrictions of maximum data
transfer frequency, defined by the SD cards).
•
It is an obvious requirement that the clock must be running for the SanDisk SD Card to
output data or response tokens. After the last SPI bus transaction, the host is required
to provide 8 (eight) clock cycles for the card to complete the operation before shutting
down the clock. Throughout this 8-clock period, the state of the CS signal is irrelevant.
It can be asserted or de-asserted. Following is a list of the various SPI bus transactions:
•
A command/response sequence. Eight clocks after the card response end bit. The
CS signal can be asserted or de-asserted during these eight clocks.
•
A read data transaction; eight clocks after the end bit of the last data block.
•
A write data transaction; eight clocks after the CRC status token.
The host is allowed to shut down the clock of a “busy” card. The SD Card will complete
the programming operation regardless of the host clock. However, the host must provide a
clock edge for the card to turn off its busy signal. Without a clock edge, the SD Card
(unless previously disconnected by de-asserting the CS signal) will force the dataOut line
down, permanently.
5.10 Error
Conditions
The following sections provide valuable information on error conditions.
5.10.1
CRC and Illegal Commands
Unlike the SD Card protocol, in SPI mode the card will always respond to a command. The
response indicates acceptance or rejection of the command. A command may be rejected in
any one of the following cases:
•
It is sent while the card is in read operation (except CMD12 which is legal).
•
It is sent while the card is in Busy.
•
Card is locked and it is other than Class 0 or 7 commands.
•
It is not supported (illegal opcode).
•
CRC check failed.
•
It contains an illegal operand.
•
It was out of sequence during an erase sequence.
If the host sends a command while the card sends data in read operation then the response
with an illegal command indication may disturb the data transfer.
5.10.2
Read, Write and Erase Time-out Conditions
The times after which a time-out condition for read operations occur are (card independent)
either 100 times longer than the typical access times for these operations given below or
100ms. The times after which a time-out condition for Write/Erase operations occur are
(card independent) either 100 times longer than the typical program times for these
operations given below or 250ms. A card shall complete the command within this time
period, or give up and return an error message. If the host does not get any response with
the given time out it should assume the card is not going to respond anymore and try to