SD/MICRO-SD CARD INTERFACING
Download
Report
Transcript SD/MICRO-SD CARD INTERFACING
SD/MICRO-SD CARD
INTERFACING
MEMORY ORGANIZATION IN SD CARDS
• Like any other memory, they too have their unique address.
• The memory is divided into blocks, in many cards the length of
block can be set by user, by default it is 512 byte.
• Block is the minimum amount of data that can be transferred. . If
block length is chosen to be 512 byte ,,then address like 02h ,05h
are not permissible.
• There are 2 types of card – SD and SDHC.
• The address length is of 32 bit.
• Now in SD cards the address is given in terms of BYTE number, so
there will be 2ˆ32 =4 GB, normally card below 2GB are SD card.
• Today cards of capacity with 32 gbs are available , but length of
address is fixed ie 32 bit , so there lies the need of SDHC card ,here
the address of block is given not BYTE. If block length is chosen to
be 512 byte ,,then also address like 02h ,05h are permissible.
COMMAND FORMAT
• The command comprises of 6 byte
• First byte is 0,1,(6-bit command ).
• 2-5 is argument generally address or left as
000...
• Last byte 7- bit crc, and 1.
INITIALIZATION SEQUENCE
• First of all bring cs (chip select) low
• Give about 80 dummy cycle to initialize its registers. These
can be done by writing 10 dummy write in TX buffer of spi.
• In spi mode it is not that if u set clock to certain frequency
then it will always give that.
• It will only give clk when we write something in TX buffer,
even for read purpose we have to send some dummy
values like 0xFF.
• Then send command 0 and 1 with valid response 0x01 and
0x00 respectively.
• During these time clk frequency should be between 100k 400k ,afterwards u can increse it.
SOME IMPORTANT THINGS USING SPI
MODE
• When data is being not transmitted then the
clk value should be high.
• Phase is shown in fig.
• SD card always detect negedge and tx stuffs
are ready after some gap may be at posedge.
Card detection
• Earlier I have discussed 2 methods for detection, now i will
focus on one more method.
• The chip select(cs) of sd card have 50kΩ internal pull-up,
the idea is that we can have a external pull down resistor of
large value say 400-500k, at first this cs pin will be defined
as input interrupt and as soon as interrupt occur ,we will
declare this pin as output and continue initialization
process.
• Further if controller finds that read write process is not
going off for a long time then it can re-declare the cs as
input and read its ,if value found to be high that means card
is still present ,otherwise not and pin will remain in input
state only.
Be Aware!!
• The sd cards have their csd register which can be
assesed by CMD9 ,most of vendors allow to
manipulate the value of this register ,it also
contains the size bits ,this can be easily changed
and we have to pay for it.
• SOLUTION!! – Apply read command (CMD17) and
try to access the high address value ,if it return
wrong address error that mean you are cheated.
• The next thing you should do is to change the size
again because without it ,it may return error.
WHAT WE HAVE DONE
• The interfacing part is over.
• We have done successfully read/write
operation in most of the cards.
THANK YOU