micro SD card

Questions on control of serial busses
Post Reply
YahooArchive
Posts: 1462
Joined: Fri Oct 19, 2012 5:11 am

micro SD card

Post by YahooArchive »

I have an IC that is connected to a MicroSD Card reader. I am using a San Disk 2
GB MicroSD card.

The card reader is connected to the ARMexpress LITE as follows:

CS -> pin 6
input -> pin 9
clock -> pin 7

Here is the code that I tried to test it:

#include <SPI.bas>

DIM X$(10)

X$=chr(50)

PRINT X$

SPIOUT (6,7,9,0,1,X$)



I am sure there is a glaring error in what I have done, I am having trouble
finding too much documentation on this issue.

If anyone can give me any help it would be greatly appreciated.



YahooArchive
Posts: 1462
Joined: Fri Oct 19, 2012 5:11 am

Re: micro SD card

Post by YahooArchive »

Just looking at the spec for a generic SD card, the command sequence is much
more complex than sending a single byte. It involve a bi-directional sequence
of 7 bytes out and 1-2 bytes coming back.

YahooArchive
Posts: 1462
Joined: Fri Oct 19, 2012 5:11 am

Re: micro SD card

Post by YahooArchive »

> Just looking at the spec for a generic SD card, the command sequence is much
more complex than sending a single byte. It involve a bi-directional sequence
of 7 bytes out and 1-2 bytes coming back.
>

Thanks, do you know where I can find examples/information on this? I have looked
everywhere.

YahooArchive
Posts: 1462
Joined: Fri Oct 19, 2012 5:11 am

Re: micro SD card

Post by YahooArchive »

> Thanks, do you know where I can find examples/information on this? I >have
looked everywhere.
>

To do this from scratch is going to be a major project. That's why I've used
boards that handle all the details for me, like

http://www.sparkfun.com/commerce/produc ... ts_id=8215

But if you really want to do it from scratch

http://www.sandisk.com/Oem/Manuals/

You might check some other forums for sample code

YahooArchive
Posts: 1462
Joined: Fri Oct 19, 2012 5:11 am

Re: micro SD card

Post by YahooArchive »

>
> You might check some other forums for sample code
>

I did this (in C not basic) but it was way harder than I expected. You can use
SPI but you have to first use the native mode of the SD spec to tell it to
switch to SPI. The bigger hurdle by far is the code you have to write to handle
the FAT file system on the card. I've heard people say they just treated it like
serial memory but I don't know how and if you do that you will wipe out the FAT
format which is optimized for each card. Nothing else will ever be able to read
that card. There are also different SD specs for different cards (ver 2 vs 1,
HC, etc.). My advice is use one of the boards Bruce links to above. You
mentioned an IC, maybe you already are doing this and we misunderstood. Good
luck.

YahooArchive
Posts: 1462
Joined: Fri Oct 19, 2012 5:11 am

Re: micro SD card

Post by YahooArchive »

I used other arm7 samples as a basis for my sd code.
I can't remember if it works or not, I remember struggling
with spi also.

There is (I have somewhere at home) a somewhat generalized arm7 fat library out
there, (check the lpc2000 yahoo group). All it needs is a hardware interface
layer to work.

When I get back on coridium hw I will see what works with sd.

basicchip
Posts: 1090
Joined: Fri Oct 19, 2012 2:39 am
Location: Weeki Watchee, FL
Contact:

Re: micro SD card

Post by basicchip »

--- In ARMexpress@yahoogroups.com, "espnleague" wrote:
>
> --- In ARMexpress@yahoogroups.com, "basicnode" wrote:
> >
> > Just looking at the spec for a generic SD card, the command
sequence is much more complex than sending a single byte. It involve
a bi-directional sequence of 7 bytes out and 1-2 bytes coming back.
> >
>
> Thanks, do you know where I can find examples/information on this?
I have looked everywhere.
>

I've just written a couple of libraries in Oberon-07 for Armaide to
enable block read / write access to SD Cards using SPI0. If you want
to write similar code from scratch yourself a good starting point is
the NXP Application Note AN10406 "Accessing SD/MMC Card using SPI on
LPC2000, V3 (Jan 3, 2007)" which you can download from:


http://www.standardics.nxp.com/support/ ... ntrollers/

Chris Burrows
http://www.cfbsoftware.com/armaide

Post Reply