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
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.
Previous article:SD card read CID register
Next article:ucOS Learning Notes (6) - Porting ucOS to STM32 step by step
Recommended Content
Latest Microcontroller Articles
He Limin Column
Microcontroller and Embedded Systems Bible
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
MoreSelected Circuit Diagrams
MorePopular Articles
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
MoreDaily News
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
Guess you like
- About the problem of data transmission between AD7768 evaluation board and sdp-h1 board
- [RPi PICO] Some examples from enthusiast Roberthh
- Free e-book download | "ADI System Solutions Selection Volume 6"
- Prize-winning quiz | Bringing life to buildings ADI Building Smoke Detection Technology
- In a bus communication system, how to automatically assign addresses to slaves.
- What parameters should I look at when selecting a TVS? Can anyone tell me?
- Are flow and reflow the same thing?
- What every electronics engineer should know about oscilloscopes
- Hot Must-Read丨20 Questions and Answers from Data Converters (ADI)
- Agilent E3632A Repair