Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronic 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.

Register Log in

Receiving data from SD card in SPI mode

Status
Not open for further replies.

ptjw

Junior Member level 3
Joined
Apr 29, 2011
Messages
29
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,597
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 data...so 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:
 

permute

Advanced Member level 3
Joined
Jul 16, 2010
Messages
923
Helped
294
Reputation
588
Reaction score
267
Trophy points
1,343
Activity points
8,543
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).
 

ptjw

Junior Member level 3
Joined
Apr 29, 2011
Messages
29
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,597
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?

thanks!
 

permute

Advanced Member level 3
Joined
Jul 16, 2010
Messages
923
Helped
294
Reputation
588
Reaction score
267
Trophy points
1,343
Activity points
8,543
It should be, and keep in mind that the protocol does have possible busy states and a block checksum.
 

Status
Not open for further replies.
Toggle Sidebar

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top