Continue to Site

Welcome to

Welcome to our site! is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Receiving data from SD card in SPI mode

Not open for further replies.


Junior Member level 3
Apr 29, 2011
Reaction score
Trophy points
Activity points
hello all,

i am to configure a spartan 3A to interface with a SD card reader in SPI mode using MOSI, MISO, CS and CLK.

i have written code in VHDL to implement this, but cannot verify whether it works until the actual hardware is here (which is still a few weeks away).

i currently have a few simple questions:

lets say i have a txt file in the SD card called abc.txt with the text 'abc' inside. i know that to access a block of data (512 bytes) from a SD card in SPI mode i would have to send CMD 17 (read block) to the SD card. i know that CMD17 requires an address argument to be sent to the SD card, specifying where on the card do i want the how do i find the address of the txt file?


i used winhex and opened a SDcard connected to my computer, i created the abc.txt file with the text 'abc'. from what i can see from winhex, does it mean that the address i have to specify is 0422EE00?

also, would the reply from the SDcard be (plain and simply) 'abc' in binary form? eg: 61h 62h 63h -> 01100001 01100010 01100011

thats all the questions i have for now, would appreciate any help! :grin:

so how do i find the address of the txt file?
you are using a file system. you would need to use its mechanisms for finding and retrieving files.

the sd card is essentially a block device. so you'd get blocks of data back. likewise, you'd need a block address. notice that the file starts on a 512B boundary? the block is then 0x0422EE00 / 0x200 = 0x21177. a read of that block will return 512B. (for sd, more for some of the SDHC formats).

oh ok i think i get it, SD cards are accessed in blocks of 512bytes!

but will the data sent over the MISO be the binary equivalent of 'abc'? 01100001 01100010 01100011?


It should be, and keep in mind that the protocol does have possible busy states and a block checksum.

Not open for further replies.

Part and Inventory Search

Welcome to