SD/MicroSD via SPI Interface


#1

Hi All!

Is it possible to connect SD/microSD dataflash card via one of SPI interface for example on Q2686?
Whether experience at somebody with it or even representation about it was?

Is SD protocol “shared”? Maybe better use MMC(MultiMediaCard)?


#2

Yes, i can say it’s definately possible, altough i only interfaced with flash-chips so far, which has a little bit simplier interface protocoll, altough the basic SPI SD card protocoll ( which is supported by all card as far as i now ) is also simple.

Here is the website for you:
http://www.sdcard.org/

The SD card is basicly an MMC card without some fancy feature and in a different package.

Before you start here are the Open AT OS-s without a stable SPI bus API, so don’t use it.
6.63
7.0 beta
Here are the OSs which i found OK for the SPI bus
6.63c
(7.1)

updated
7.1 - has some nasty problem on SPI

And please take everything from me with a little grain of salt, because nowadays i can say a lot of nonsense things. :slight_smile:


#3

What is the nasty SPI problem with 7.1?


#4

This is exactly what I am trying to get going now.

I have it working on an external MCU with direct bit banging. Works OK, but very slow. It may sound simple to implement but is actually quite tricky if you expect it to be like EEPROM (which seems to be the way the Wavecom SPI API is built).

A few pointers:
*CS does not reset comm state. It merely tells the chip to listen and respond. This means CS can go up and down for nearly every byte (have not tested this for the first few command bytes).

*microSD spec apparently does not require the manufacturer to implement SPI mode. Not sure where I read this. Better to stick with proper sized SD cards under or equal to 2GB. I suppose this accounts for many incompatibility issues like the Samsung D900 only working regularly with SanDisk cards and requiring some absurd camera operations to get Kingston going (this might accidentally init the SD SPI mode or something).

*The initial response from the card differs between brands and from the spec. It’s quite useful to send a dummy GO_IDLE, flush out a few bytes and then do it again in a proper manner.

*Responses are NOT guaranteed to come at a specific/byte clock position. You must keep the clock running until you see the relevant token or status byte(s).
Since wavecom works in buffer style, you will typically read 700 bytes for a 512 block to be sure that the responses will be in there somewhere. Writing a block is also tricky since you must put out start bytes, data, CRC and then check the response byte. However, during the write operation the card might return an error token which you will miss because the wavecom API does not allow you to read while writing.

*The idle line state is high. Wavecom seems to do this the other way round which will make things difficult if not impossible.
I will probably keep the SD card on the external MCU, but was wondering if it might be possible to change the default line idle state (to high). If no one can tell me how (API does not seem to allow for it) I’ll forget about it for now.

*Read read and read the spec (the simplified version is free from sdcard.org). Make sure you implement CRC7 properly (also turn it on, default is off) and follow the flow charts for the initialisation process.

For a good example, see www.maxim-ic.com for an app note on SD. TI has an MMC example, but there are in fact one or two differences between SD and MMC.

One last note, Wavecom’s SPI example seems to use something that does not exist:
adl_busSPISettings_t SpiSettings =
{
5, // Clk_Speed (2 MHz)
ADL_BUS_SPI_CLK_MODE_0, // Clk_Mode;
ADL_BUS_SPI_ADDR_CS_GPIO, // ChipSelect;
ADL_BUS_SPI_CS_POL_LOW, // ChipSelectPolarity;
ADL_BUS_SPI_MSB_FIRST, // LsbFirst;
ADL_IO_GPIO | 35, // GpioChipSelect;
ADL_BUS_SPI_FRAME_HANDLING, // WriteHandling; <------ where in the struct is this???
ADL_BUS_SPI_DATA_UNIDIR, // DataLinesConf;
ADL_BUS_SPI_MASTER_MODE,
ADL_BUS_SPI_BUSY_UNUSED
};

rather use
adl_busSPISettings_t p;

p.Clk_Speed = 99; //13MHz/(1+n)
p.Clk_Mode = ADL_BUS_SPI_CLK_MODE_2;
p.ChipSelect = ADL_BUS_SPI_ADDR_CS_GPIO;
p.GpioChipSelect = ADL_IO_GPIO | 31; //this looks wrong but it works
p.ChipSelectPolarity = ADL_BUS_SPI_CS_POL_LOW;
p.LsbFirst = ADL_BUS_SPI_MSB_FIRST;
p.LoadSignal = ADL_BUS_SPI_LOAD_UNUSED;
p.DataLinesConf = ADL_BUS_SPI_DATA_UNIDIR;
p.MasterMode = ADL_BUS_SPI_MASTER_MODE;
p.BusySignal = ADL_BUS_SPI_BUSY_UNUSED;

#5

Has anyone or company written SD/MMC driver for Q26? If deos, how much for a copy? Thanks.


#6

sorry for my late reply
U can use load or in place of this ADL_BUS_SPI_FRAME_HANDLING one u can use.
finally u solved this problem. i am working now this project . can u give suggestion how can i archive this task
plz help me out…


#7

i think maybe some companies implemented…i am working on now same task.
if u got this task can u copy to me…
thanks
kiran