SparkFun Forums 

Where electronics enthusiasts find answers.

Everything ARM and LPC
By Gorlash
#163866
Okay, the next feature I need to implement on our card is support for an SD card. I've looked at ST's SSP examples, but they all just do loopback operations, and none of them say anything about dealing with an SD card. I'm assuming that if I call SSP_SendData() and SSP_ReceiveData(), that is going to simple read/write data... how do I interact with the command interface on the chip? On USB, this was a SCSI controller, or at least had a SCSI interface behind the USB interface, but SD is not USB... is it??

The reason I ask like that, is I found a STR9 SD card example in the IAR example code, but that code ultimately reduces the commands to USB code, and interacts with the 91x_usb.c module... that doesn't make any sense??

I also found lots of STM32 code which interacts with a SDIO module, but I suspect that this is an STM32 interface that the STR91x does not have.

Can anyone give me any hints on this??
By Gorlash
#163895
Hmmm... okay, I think I'm starting to get this now. Found a good, thorough description of the process at:
http://elm-chan.org/docs/mmc/mmc_e.html
Good descriptions of SPI interface, initialization, and command set.
One thing that's a little different is that my chip handles SPI with separate hardware, so I don't actually have control of the bits themselves. I'll have to drag out a scope and see if it does the 74-clock init sequence or not?? Hopefully it does, since it handled I2C details correctly.

So, my interpretation is that I'll use SPI commands to get the SD card initialized, then wrap SCSI commands inside SPI block-write commands, is that correct? At least, that's how I handled USB cards, back when I was working on them...
Or do I ignore SCSI entirely, and just use SPI block-write commands to write blocks, and SPI block-read commands to read blocks? Most examples that I've seen, seem to be using SCSI interface to talk to SD cards, though the above site does not mention SCSI...
By Gorlash
#163929
Okay, after poring through the IAR STR9 code for a couple of hours, I now understand what is going on...

The IAR example *does* contain a SD-card driver, but it does more than that... it is intended to be plugged into a PC via USB, and make the board and SD card look like a removable drive to the PC!! The USB/SCSI code is used for the PC interface!! So that has nothing to do with SD at all. It confused me somewhat because they have SD and USB/SCSI interfaces combined in one file (lun.c).

I think I understand which parts are SD interface now... I'll start integrating the init code and see if I can get those first functions to work.

Thank you for your example code, UhClem; I'll study it as well.