This Post marks the beginning of our quest to develop a simple Music player. SD stands for Secure digital and these small devices have been around for a while now. They contain flash memory and a memory controller which is given instruction by the main MCU. So our main objective here is to understand how sd cards work and how to interface them with a microcontroller. As to understand the working of SD card we need to dive into the world of transistors and bits!
The Sd card contains solid-state memory also known as the flash memory which is a type of EEPROM i.e Electronically Erasable Programmable Read Only Memory. Flash memory stores information in an array of memory cells made from floating-gate transistors. These transistors are used in different topologies as to store each bit. We will not program each bit individually as it will be time-consuming as well as an inefficient way to store the data. As to move to a higher level of abstraction, we need a way to store our data at a specific memory location and for this, each memory card comes with an integrated controller so that we don't need to dive to the lower levels to store our data. This controller can be used with some standard communication protocols such as SDIO and the SPI(Serial Peripheral Interface). Here, we'll be using the SPI protocol as it is one of the most popular communication protocol in the MCU’s. Many of the available components such as TFT display drivers such as ST7735 can be interfaced by using it. The SPI is explained in a dedicated post under Introduction to Embedded Systems section.
Each command for the SD card requires a special format as shown below:-
There are various commands for different functions provided by the manufacturer as to control the functioning of the sd card. These commands along with there specific arguments and response are listed below.
As to use the SD-CARD for any function we first need to initialize it by using a specific combination of commands which is shown below:-
So let us start by sending the first command CMD0 and recording the response. Before this, each sd card resets in SDIO interface mode and requires 80 dummy clock cycles as to move to SPI interface mode:-
Now we can send the CMD0:-
The response 0x01 is the legal response and hence we can move to the next command i.e CMD58 as to check the operating conditions and verify whether the correct voltage level is provided to the SD- CARD:-
Now we begin the process of initializing the card by sending the combination of CMD55 and ACMD41 continuously until the response changes to 0x00 which marks the end of initialization.
CMD58 can then be sent again to check whether it is High capacity or Standard capacity. If all of the above steps are performed with success then we will be able to move to the data storage part which is discussed in the next blog.
The Sd card contains solid-state memory also known as the flash memory which is a type of EEPROM i.e Electronically Erasable Programmable Read Only Memory. Flash memory stores information in an array of memory cells made from floating-gate transistors. These transistors are used in different topologies as to store each bit. We will not program each bit individually as it will be time-consuming as well as an inefficient way to store the data. As to move to a higher level of abstraction, we need a way to store our data at a specific memory location and for this, each memory card comes with an integrated controller so that we don't need to dive to the lower levels to store our data. This controller can be used with some standard communication protocols such as SDIO and the SPI(Serial Peripheral Interface). Here, we'll be using the SPI protocol as it is one of the most popular communication protocol in the MCU’s. Many of the available components such as TFT display drivers such as ST7735 can be interfaced by using it. The SPI is explained in a dedicated post under Introduction to Embedded Systems section.
Each command for the SD card requires a special format as shown below:-
There are various commands for different functions provided by the manufacturer as to control the functioning of the sd card. These commands along with there specific arguments and response are listed below.
As to use the SD-CARD for any function we first need to initialize it by using a specific combination of commands which is shown below:-
So let us start by sending the first command CMD0 and recording the response. Before this, each sd card resets in SDIO interface mode and requires 80 dummy clock cycles as to move to SPI interface mode:-
Now we can send the CMD0:-
The response 0x01 is the legal response and hence we can move to the next command i.e CMD58 as to check the operating conditions and verify whether the correct voltage level is provided to the SD- CARD:-
Now we begin the process of initializing the card by sending the combination of CMD55 and ACMD41 continuously until the response changes to 0x00 which marks the end of initialization.
CMD58 can then be sent again to check whether it is High capacity or Standard capacity. If all of the above steps are performed with success then we will be able to move to the data storage part which is discussed in the next blog.








Comments
Post a Comment