SD card SPI mode initialization sequence

Publisher:HarmonyInLifeLatest update time:2016-07-14 Source: eefocus Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
In order to initialize the SD card into SPI mode, we need to use three commands: CMD0, ACMD41, CMD55 (CMD55 should be sent before using ACMD commands, CMD55 plays a role in switching to ACMD commands). 
Why not use CMD1 after using CMD0? CMD1 is the command used by MMC cards. Although this article does not want to discuss the issue of MMC cards, I still want to say: In order to achieve compatibility, after powering on or sending CMD0, you should first send CMD55+ACMD41 to confirm whether there is a response. If there is a response, it is an SD card. If the response timeout occurs, it may be an MMC card, and then send CMD1 to confirm. 
The correct response content should be:
    CMD0——0x01 (SD card is in-idle-state)
    CMD55——0x01 (SD card is in-idle-state)
    ACMD41——0x00 (SD card jumps out of in-idle-state, completes initialization and prepares to receive the next instruction)
    What I want to say here is that if the final response content is still 0x01, you can send CMD55+ACMD41 in a loop until the response content is 0x00. 
Among all the instructions, only CMD0 is special. Before sending it to the SD card, 74+ clocks need to be sent to the SD card. So why 74 CLKs? Because at the beginning of power-on, the voltage rise process is calculated by the SD card organization to reach the normal working voltage of the SD card in about 64 CLK cycles. They call this Supply ramp up time. The subsequent 10 CLKs are for synchronization with the SD card. After that, the operation of CMD0 is started. If you strictly follow this operation, there will be no problem. 
Regarding the SPI bus of the SD card, when reading data, the SPI of the SD card is input latched on the rising edge of CLK, and the output data is also on the rising edge. 
The process of writing a CMD or ACMD instruction to the SD card is as follows:
first, make CS low and enable the SD card; secondly, write the instruction to the Din of the SD card; after writing the instruction, add 8 filling clocks to complete the internal operation of the SD card; then receive the response on the Dout of the SD card; after receiving the response, make CS low and add 8 filling clocks. 
When there is no data written to the Din of the SD card, Din should be kept high.
Reference address:SD card SPI mode initialization sequence

Previous article:SD card read CID register
Next article:ucOS Learning Notes (6) - Porting ucOS to STM32 step by step

Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号