SD Host Operation
A command is a token that triggers an operation. A response is a token sent from an addressed card by answering the request from the SD host controller. The commands and responses are transferred through the CMD port. When the communication is formed and confirmed at both ends, the data can be transferred from the card to the SD host controller or vice versa via DATA ports. The SD host controller uses command tokens to communicate with the SD card and wait for the response from the SD card. Then the SD host controller transfers or receives streams of data from or to the SD card.
Initialization
During power-on, the SD Host Controller core must go through the initialization and identification process before transferring any data. This is mainly due to the SD Host Controller core needing to retrieve the SD card's basic information and ensure the card is ready to be accessed.
Block Read and Multiple Blocks Read
The SD Host Controller core supports single and multiple blocks read. A
basic unit of a block has a maximum size of 512 bytes. Send a CMD17
command to let the SD card know it is a single block read. For multiple blocks read,
send a CMD18 command as a start indicator, followed by receiving
consecutive data blocks, and end it by issuing CMD12 command to
indicate a stop transmission.
Block Write and Multiple Blocks Write
The SD Host Controller core supports single and multiple blocks write.
A basic unit of a block has a maximum size of 512 bytes. Send a
CMD24 command to let the SD card know it is a single block
write. For multiple blocks write, send a CMD25 command as a start
indicator, followed by writing consecutive data blocks, and end it by issuing
CMD12 command to indicate a stop transmission.
ADMA Transfer
The SD Host Controller core supports advanced direct memory access (ADMA) data transfer. This transfer mode is usually executed when you transfer a large amount of data multiple times to or from the SD card.
You need to create a descriptor list and store it in system memory. The maximum transfer for each descriptor is 65536 bytes, including a target address. If you want to transfer more than that, you need to create multiple descriptors. After creating the descriptor list, start the ADMA, and the SD host automatically fetches the descriptor from system memory and starts the data transfer according to the list. The last descriptor must contain a stop bit information to indicate that it is the final data transfer. The ADMA interrupts the CPU once the final descriptor is executed and the transfer is completed.