SD card function description
Communication between all hosts and SD cards is controlled by the host, which is consistent with that of USB. For example, the USB flash drive does not actively notify the USB controller, the USB mouse does not have the ability to actively notify the USB controller. Of course, the SD card does not have the ability to actively notify the SD controller.
The host sends two types of commands: one is one-to-multiple, and the other is one-to-one. They are:
1.Broadcast command: Broadcast commands are sent to all SD cards mounted on the SD bus. Some broadcast commands require the SD card to respond.
2.Addressing (point-to-point) commands: The addressing command only sends a response to the card with the corresponding address that needs to be found.
There are two SD card modes: Card recognition and data transmission.
1.Card recognition Mode: After the reset (reset), when the host finds a new card on the bus, it is in the card recognition mode. After resetting, the SD card will always be in this mode until you receive the send_rca command (cmd3 ).
2.Data Transmission Mode: When the card receives the RCA (cmd3), the card enters the data transmission mode.
In general, there are 10 states in the two card operation modes. These two operation modes run through the essence of the entire protocol, so we need to know about them.
Next, we will translate the initial recognition mode of sd3.0 card. This translation is boring, but it is not feasible. It is indeed complicated. It is hard to understand how this process is implemented without careful consideration of English.
Card recognition mode:
In card recognition mode, the host resets all SD cards in card recognition mode, checks the operating voltage range, identifies the card, and requests the card to send the relative card address (RCA ). These operations are completed on their respective cmd lines. In the process of card recognition, the operating frequency of the card should be under fod.
Card Reset:
After sending go_idle_state (idle 0) to the SD card, all SD cards except inactive state enter the idle state, the Cmd Line of the SD card is in input mode. The default relative address is 0x0000. The default drive register is set to the lowest speed and the maximum drive current capacity.
Work Condition Detection:
Before the Controller communicates with the SD card, the controller does not know the operating voltage range supported by the SD card. Therefore, the Controller first uses the default voltage to send a reset command (Limit 0) followed by the limit 8 command, this interface is used to obtain the working voltage range data supported by the SD card. The SD card checks the operating voltage used by the Controller by detecting the parameter section of limit 8. The controller checks whether the SD card can work under the given voltage by analyzing the parameter section of limit 8. If the SD card can work under a specified voltage, it returns the command response word of limit 8, which contains check voltage and check pattern. If the SD card does not support the supplied voltage, the SD card will not provide any response information and remain in the idle status. In plv2.0 (Physical Layer version2.0), before executing acmd41 for the first time, you must run the ipv8 command to initialize the sdhccard. The sdhccard verifies whether the Controller supports the plv2.0 protocol based on whether the ipv8 command is received. To use a low-voltage controller, you must also send limit 8 before the acmd41 command to avoid working SD cards in two voltage modes because they do not receive limit 8, which works in a high-voltage environment by default, it is mistaken that only high-voltage mode is supported.
The sd_send_op_cond (acmd41) command aims to give the SD card controller a mechanism to identify whether the SD card can work within the scope of the given VDD. If the SD card cannot work within the specified VDD range, then it enters the inactive state ). Note that acmd41 is an application-related command. Therefore, each acmd41 command must be followed by an app_cmd (Limit 55) command. Run the dig 55 command in the Idle State to use the default card relative address (RCA) 0x0000.
Card initialization and identification process:
The initialization of the SD card starts after the acmd41 command is received. If the HCs (host capacity support) Bit Of The acmd command is set to 1, the Controller supports the sdhccard; otherwise, the controller does not.
The acmd41 Command sent after the iis8 command has extended its functions. The HCs section is added to the parameter, and the CCS (card capacity status) section is added to the response. The HCs parameter is discarded by SD cards that do not respond to the iis8 command. When the controller sends the acmd41 command to a card that does not respond to listen 8, the HCs bit should be set to 0. If an acmd41 command with a HCs bit of 0 is sent to the sdhccard, the response returned by the sdhccard will always have a busy flag of 0, which indicates the active state. The HCs flag is used to indicate whether the SD card has been initialized. If not, HCs is zero; otherwise, it is 1. If HCs is 0, the Controller will repeatedly send the acmd41 command, the SD card only checks the HCs bits of the acmd41 command received for the first time.
The response to the acmd41 Command sent from the SD card in response to iis8 contains the CCS part. The controller only checks the CCS contained in the response with the HCs flag 1. CCS = 1 indicates it is an sdhccard, otherwise it is a standard SD card.
The Controller then sends the all_send_cid (cmd2) command to query the CID (unique card identification) values of each card. The unrecognized SD card (in ready state) will send the CID value as a response, after the CID value is sent, the SD card enters the identification state, and the controller sends the cmd3 (send_relative_addr) command, requiring each SD card to send a new relative address (RCA ), RCA is used for addressing in later data transmission modes. After the RCA is sent. The SD card enters the stand-by State. In this state, if the Controller wants to assign a new RCA to the SD card, it can send another cmd3 command to the SD card. The last release is the real RCA of the SD card.
The process for card initialization and identification is as follows (SD mode ):
Summary process:
When the host is powered on, it puts all the card devices in the card recognition mode and completes the operations such as setting the effective operation voltage range, card recognition and the relative address of the Request Card.
1. Send the instruction limit 0 so that the card device is in the idle status;
2. send command route 8. If the card device has response, it indicates that the card is sd2.0 or above;
3. Send the command serial 55 + acmd41, which is used to detect whether the operating voltage of the card device meets the requirements of the host. Before sending commands such as acmd41, send the serial 55 command, in sdio, The acmd41 command is replaced by limit 5.
4. Send the command 201711 to convert the operating voltage to 1.8 V;
5. Send the command cmd2 to obtain the CID;
6. Send the command cmd3 to obtain the RCA (relative card address)
Now, I will talk about this article. Do you have a clearer understanding of the SD card initialization and identification process? This is only a Protocol process. The specific code implementation will be analyzed later. You must never rush ~~