CMP EMBEDDED.COM

Embedded On Demand Login | Register     Welcome Guest Embedded On Demand
HOME DESIGN PRODUCTS COLUMNS E-LEARNING CONFERENCES CODE FORUMS/BLOGS NEWSLETTERS CONTACT FEATURES RSS RSS

Thread: Interfacing with SD Card via SPI

 
This question is not answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 3 - Pages: 1 - Last Post: Nov 9, 2009 8:51 PM Last Post By: cfbsoftware Threads: [ Previous | Next ]
BrettB

Posts: 2
Registered: 11/06/09
Interfacing with SD Card via SPI
Posted: Nov 6, 2009 5:36 PM
 
  Click to reply to this thread Reply
I am trying to interface to an SD card via a SPI bus. I am able to communicate with the card to initialize it and read the CSD and CID registers. It looks like I am able to read data. When I send the read data command for address 00000000, I get all 0s back. However, when I try to write data to the card, I get a response token of 0x40, which means "Parameter Error". I have tried this with several different addresses and get the same results. Does anyone have any ideas? How do you know what the address space of an SD card is? I have not been able to find that documentation anywhere.
cfbsoftware

Posts: 7
Registered: 05/28/09
Re: Interfacing with SD Card via SPI
Posted: Nov 7, 2009 5:53 PM   in response to: BrettB in response to: BrettB
 
  Click to reply to this thread Reply
I don't know the answers to your specific questions but when we implemented the SPI / SD Card code to use in Armaide we found the NXP Application note "AN10406 Accessing SD/MMC Card using SPI on LPC2000" invaluable:

http://www.standardics.nxp.com/support/documents/?type=appnote

Even if you are using an MCU from a different family I believe that it gives a general enough view of the steps involved to be helpful.

--
Chris Burrows
CFB Software
Armaide: ARM Oberon-07 Development System
http://www.armaide.com
BrettB

Posts: 2
Registered: 11/06/09
Re: Interfacing with SD Card via SPI
Posted: Nov 9, 2009 11:18 AM   in response to: BrettB in response to: BrettB
 
  Click to reply to this thread Reply
It looks like my problem was caused by me trying to write to a smaller block than the default 512 bytes. The few SD cards that I have tried, do not allow partial block writes according to bit 23 of their CSD registers. Does anyone know of any SD Cards that will allow smaller block writes?
cfbsoftware

Posts: 7
Registered: 05/28/09
Re: Interfacing with SD Card via SPI
Posted: Nov 9, 2009 8:51 PM   in response to: BrettB in response to: BrettB
 
  Click to reply to this thread Reply
AFAICS the permitted block sizes depend on whether you are using Standard Capacity (< 2GB) and High Capacity (> 2GB) SD Cards. You need to use a Standard Capacity card if you want to use block lengths < 512 bytes.

Chris

Point your RSS reader here for a feed of the latest messages in all forums




 :