Searching \ for '[BUY] Help with microSD or SD card interfacing' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/index.htm?key=help+with+microsd
Search entire site for: 'Help with microSD or SD card interfacing'.

Exact match. Not showing close matches.
PICList Thread
'[BUY] Help with microSD or SD card interfacing'
2007\03\30@131221 by James Newtons Massmind

face picon face
Is there anyone in the So Cal (e.g. from San Diego to L.A.) who has direct
experience with any of the following:

- Hooking an SD card to a micro.
- Hooking a microSD card to a micro
- Using SPI mode on a SD or microSD card.
- Using SD 1 bit mode on a SD or microSD card.
- Using SD nibble mode on a SD or microSD card.
- Verifying SPI mode communications.
- SPI comms on the MSP430.

I'm quite a few hours into attempting to connect a microSD (aka TransFLASH)
card to an MSP430F1611 and I'll be damned if I can get any response back
from the card.

I've read the datasheets, I've read the many available web pages on the
subject, I've checked, re-checked, double checked and had others check the
connections, and I'm looking at the signals I'm putting out on a logic
analyzer and they are dead on exactly what is called for. And there is NO
response from x4 cards.

I've verified that  all the cards we have are working via an SD card adapter
to a reader in a USB hub, but I doubt that is using SPI mode. We purchased
microSD cards from Transcend with datasheets that specify that they DO
support SPI mode (which is optional on microSD).

Nothing.

It's time to put pride aside and call for help. We can pay a reasonable fee
for anyone who has done this before, especially if you have a working unit
that uses SPI that we can verify our cards in and watch the signals on.

If you are not in the area, but could possibly post a screen shot of the
actual signals you are putting out, that would also be worthwhile.

Thanks in advance.

---
James Newton: PICList webmaster/Admin
spam_OUTjamesnewtonTakeThisOuTspampiclist.com  1-619-652-0593 phone
http://www.piclist.com/member/JMN-EFP-786
PIC/PICList FAQ: http://www.piclist.com


2007\03\30@134234 by Philip Pemberton

face
flavicon
face
James Newtons Massmind wrote:
> Is there anyone in the So Cal (e.g. from San Diego to L.A.) who has direct
> experience with any of the following:
>
> - Hooking an SD card to a micro.

I'm not in SoCal, but I've done that... Got PIC code for it somewhere, too.

> - Using SPI mode on a SD or microSD card.

Been there, done that, stole the T-shirt from an unmanned T-shirt stand :P

> I'm quite a few hours into attempting to connect a microSD (aka TransFLASH)
> card to an MSP430F1611 and I'll be damned if I can get any response back
> from the card.

Have you got any uploadable scope/logic analyser traces of the comms lines
during the startup burst?

IIRC you need to send a CMD40 (or something like that) to the card until it
responds with a '1' bit, else the card just sits there dead.

> I've read the datasheets, I've read the many available web pages on the
> subject, I've checked, re-checked, double checked and had others check the
> connections, and I'm looking at the signals I'm putting out on a logic
> analyzer and they are dead on exactly what is called for. And there is NO
> response from x4 cards.

Is there any response from other types of card?

> If you are not in the area, but could possibly post a screen shot of the
> actual signals you are putting out, that would also be worthwhile.

Give me a couple of days to shift this coursework and I'll drag my HP1651B and
cables out of the cupboard and do some screenshots. Assuming I can remember
how the 'grabber' software works, that is...

--
Phil.                         |  (\_/)  This is Bunny. Copy and paste Bunny
.....piclistKILLspamspam@spam@philpem.me.uk         | (='.'=) into your signature to help him gain
http://www.philpem.me.uk/     | (")_(") world domination.

2007\03\30@134612 by Harold Hallikainen

face
flavicon
face
If the microSD uses the same signaling as the SD, I could possibly help. I
have 18 series asm and C code to talk with MMC/SD cards using SPI.

Harold


{Quote hidden}

> -

2007\03\30@141313 by John Chung

picon face
Hi James,

 I haven't done SD interfacing yet. I am still doing
some research on my side. There is one forum in
particular which you may want to check out, Parallex.
Some of the guys there have been fooling around with
the SD cards. You may want to ask them how to access
the card there. Generally SPI works well with SD
cards, I am not sure why this is not working. The
timing for clocking and data is a bit on the tight
side but this should not be a problem.

Regards,
John

--- James Newtons Massmind <.....jamesnewtonKILLspamspam.....massmind.org>
wrote:

{Quote hidden}

> --

2007\03\30@171816 by James Newtons Massmind

face picon face
Hang on, some of the responses have led me to think I might know the
problem...

Is it true that you don't get a response to the first CMD0? You have to keep
sending CMD0 until you do get a reply?

I was ASSuMEing that since the card had been in the socket for a good long
time with power applied, all I have to do is send the 80 clocks and then ONE
CMD0 and it should pop up with a response. I've been stopping after one all
this time.

---
James.



> {Original Message removed}

2007\03\30@181053 by Herbert Graf

flavicon
face
On Fri, 2007-03-30 at 14:18 -0700, James Newtons Massmind wrote:
> Hang on, some of the responses have led me to think I might know the
> problem...
>
> Is it true that you don't get a response to the first CMD0? You have to keep
> sending CMD0 until you do get a reply?

In the working code I have, after you send CMD0, you then keep clocking
in the response until you receive 0xFF.

I've seen code that uses a timeout here in case there is no card
inserted, in my case I didn't do that since if there is no card inserted
there was nothing else for me to do anyways! :)

Thanks, TTYL

2007\03\30@181931 by Philip Pemberton

face
flavicon
face
James Newtons Massmind wrote:
> Is it true that you don't get a response to the first CMD0? You have to keep
> sending CMD0 until you do get a reply?
>
> I was ASSuMEing that since the card had been in the socket for a good long
> time with power applied, all I have to do is send the 80 clocks and then ONE
> CMD0 and it should pop up with a response. I've been stopping after one all
> this time.

There's a decently-written startup procedure in the Renesas MultimediaCard
product manual (most of what's said in the MMC manual still holds for SD Cards
too, BTW). Basically:

1. Send 80 clocks with /CS inactive (high)
2. Make /CS active (low), transmit a CMD0 command -- note that the card is in
MMC mode with CRCs enabled, so send the sequence 40,00,00,00,00,95 [hex]
3. Now the card is in SPI mode. Wait for an R1 response from the card.
4. If the R1 response is 0x01, proceed. If any other response is received,
assume there's no card in the slot and either restart the init sequence from
scratch, or display an error message on the device's LCD.
5. Send a CMD1 command (SEND_OP_CMD) and poll for an R1 response
6. If the response is 0x00, the card has finished initialising. If it is 0x01,
go back to step 5, and repeat until R1response = 0x00.

Basically, CMD0 forces the card to wake up, CMD1 returns the current state of
the card - when the LSBit (IN IDLE STATE) is high, the card is running its
initialisation procedure. When the LSBit goes low, the initialisation has
finished and the card will action READ, WRITE, ERASE, etc. commands.

You need to get the sequence right, otherwise the card will just sit and play
dead.

--
Phil.                         |  (\_/)  This is Bunny. Copy and paste Bunny
piclistspamspam_OUTphilpem.me.uk         | (='.'=) into your signature to help him gain
http://www.philpem.me.uk/     | (")_(") world domination.

2007\03\30@191348 by James Newton, Host

face picon face
> From:  Philip Pemberton

> There's a decently-written startup procedure in the Renesas
> MultimediaCard
> product manual (most of what's said in the MMC manual still
> holds for SD Cards
> too, BTW). Basically:
>
> 1. Send 80 clocks with /CS inactive (high)

Check, although the SD spec says with /CS low, I've tried it both ways.

> 2. Make /CS active (low), transmit a CMD0 command -- note
> that the card is in
> MMC mode with CRCs enabled, so send the sequence
> 40,00,00,00,00,95 [hex]

Check. I can see it on the scope. Clocking data on the positive clock
transition.

> 3. Now the card is in SPI mode. Wait for an R1 response from the card.

Ok, now what exactly does that mean? As I read the spec and the sample
programs, after that CMD0 string is finished, you have to clock out one full
byte (8 clocks) and then another byte, where the last clock should get a
high from the card. E.g. it should return  0x00, 0x01 after the CMD0.


> 4. If the R1 response is 0x01, proceed. If any other response
> is received,
> assume there's no card in the slot and either restart the
> init sequence from
> scratch, or display an error message on the device's LCD.

I don't get past this point. I never see the 0x01.

Further, I can pull the SDO line from the card high or low with a 100k
resistor. I.e. it is never being driven. At all. No matter what.

> You need to get the sequence right, otherwise the card will
> just sit and play
> dead.

I wish I could get you a screen shot but his old unit doesn't do that except
via an HPIB printer which I don't have. I am sending EXACTLY the right
sequence.

The only thing I can think of is that I need to send CMD0 more than once or
that I need to keep clocking until it grabs the SDO line.

>
> --
> Phil.                         |  (\_/)  This is Bunny. Copy and paste
Bunny
> @spam@piclistKILLspamspamphilpem.me.uk         | (='.'=) into your signature to help him
gain
> http://www.philpem.me.uk/     | (")_(") world domination.


I would add bunny to my sig line if he helped me solve this...

---
James Newton: PICList webmaster/Admin
KILLspamjamesnewtonKILLspamspampiclist.com  1-619-652-0593 phone
http://www.piclist.com/member/JMN-EFP-786
PIC/PICList FAQ: http://www.piclist.com


2007\03\30@191610 by James Newton, Host

face picon face
> On Fri, 2007-03-30 at 14:18 -0700, James Newtons Massmind wrote:
> > Hang on, some of the responses have led me to think I might
> know the
> > problem...
> >
> > Is it true that you don't get a response to the first CMD0?
> You have
> > to keep sending CMD0 until you do get a reply?
>
> In the working code I have, after you send CMD0, you then
> keep clocking in the response until you receive 0xFF.

Thanks Herb I just noticed that off list post, and that bit about clocking
the thing until it replies is not something I have tried. I'll do that next.


Why didn't I read the spec that way?

---
James Newton: PICList webmaster/Admin
RemoveMEjamesnewtonTakeThisOuTspampiclist.com  1-619-652-0593 phone
http://www.piclist.com/member/JMN-EFP-786
PIC/PICList FAQ: http://www.piclist.com


2007\03\30@202219 by Herbert Graf

flavicon
face
On Fri, 2007-03-30 at 16:16 -0700, James Newton, Host wrote:
> > On Fri, 2007-03-30 at 14:18 -0700, James Newtons Massmind wrote:
> > > Hang on, some of the responses have led me to think I might
> > know the
> > > problem...
> > >
> > > Is it true that you don't get a response to the first CMD0?
> > You have
> > > to keep sending CMD0 until you do get a reply?
> >
> > In the working code I have, after you send CMD0, you then
> > keep clocking in the response until you receive 0xFF.
>
> Thanks Herb I just noticed that off list post, and that bit about clocking
> the thing until it replies is not something I have tried. I'll do that next.
>
>
> Why didn't I read the spec that way?

The spec is HORRIBLE at explaining what things are. It will explain how
something is structured, but not what the bits themselves are.

It took ALOT of searching on the web to clarify things, comparing other
code examples, often conflicting code examples.

In my case I was also fighting some inconsistencies in the SPI functions
of the MCU I was using, meaning lots of time with a logic analyzer.

In the end, it's ALOT harder to figure out from scratch then it should
be. TTYL

2007\03\30@220704 by Jesse Lackey
flavicon
face
Hate to ask the obvious, have you tried several cards from different
manufacturers?  I did a SD project awhile back and everything works
EXCEPT for Sandisk cards.  They don't do nothing.  No idea why.  It
wasn't a commercial product so this bug was avoided by not using Sandisk
media.

Ironically, some of the docs I used came from Sandisk...

Also, I bet it wouldn't be the first time that the spec sheet says one
thing and the product does another.  Maybe the spec sheet is for the
next manufacturing run, "without the SPI bug"...

A few links to SPI projects... just FYI
http://www.sparkfun.com/commerce/product_info.php?products_id=544

Good luck
J


James Newtons Massmind wrote:
{Quote hidden}

2007\03\31@014900 by Philip Pemberton

face
flavicon
face
James Newton, Host wrote:
>> 1. Send 80 clocks with /CS inactive (high)
>
> Check, although the SD spec says with /CS low, I've tried it both ways.

CS high puts the card into MMC mode when it boots. The CMD0 with CS low pushes
it into SPI mode.

>> 2. Make /CS active (low), transmit a CMD0 command -- note
>> that the card is in
>> MMC mode with CRCs enabled, so send the sequence
>> 40,00,00,00,00,95 [hex]
>
> Check. I can see it on the scope. Clocking data on the positive clock
> transition.

Actually, my code clocks on the falling edge IIRC...

The code I'm using is (in pseudo-BASIC code):
  MMC_SHIFTOUT = data_to_send
  MMC_SHIFTIN = 0

  FOR MMC_LOOP = 8 DOWNTO 0 DO
    MMC_CLOCK = low                        // clock low
    delay_us(8)                                // settling delay, 8us
    MMC_SHIFTIN = MMC_SHIFTIN shl 1        // shift data in
    IF MMC_MISO == high THEN MMC_SHIFTIN = MMC_SHIFTIN or 1
                                       // shift data in
    delay_us(8)                                // settling delay
    MMC_MOSI = (MMC_SHIFTOUT and 0x80)        // shift data out
    delay_us(8)                                // settling delay
    MMC_CLOCK = high                        // clock high
    delay_us(8)                                // settling delay
  NEXT MMC_LOOP

  MMC_MOSI = high                        // make MOSI idle
  RETURN MMC_SHIFTIN                        // return MMC_SHIFTIN


>> 3. Now the card is in SPI mode. Wait for an R1 response from the card.
>
> Ok, now what exactly does that mean? As I read the spec and the sample
> programs, after that CMD0 string is finished, you have to clock out one full
> byte (8 clocks) and then another byte, where the last clock should get a
> high from the card. E.g. it should return  0x00, 0x01 after the CMD0.

An R1 response is a single byte, defined as:

MSBit             LSBit
    7 6 5 4 3 2 1 0

7: Always zero
6: Parameter error
5: Address error
4: Erase sequence error
3: Comms. CRC error
2: Illegal command
1: Erase reset
0: In idle state

You keep reading out bytes until you get the response code 0x00 (all OK, card
not in IDLE state, i.e. active).

> I wish I could get you a screen shot but his old unit doesn't do that except
> via an HPIB printer which I don't have. I am sending EXACTLY the right
> sequence.

HP 1630 or 1650 series by any chance?
I wrote a program that takes a capture of the printing sequence and converts
it into a BMP file.

> The only thing I can think of is that I need to send CMD0 more than once or
> that I need to keep clocking until it grabs the SDO line.

How are you sending the SET_OP_COND (CMD1) command?
It should be sent as six bytes: 41,00,00,00,00,FF [hex], and you need to send
it repeatedly until you get a valid response byte (0x00 or 0x01).

My WAIT_RESPONSE function clocks out a byte, checks to see if it is 0x00 or
0x01, and if it isn't it goes back and clocks out another byte. When the card
returns 0x00 or 0x01, it returns the value and exits.

It sends CMD0, waits for a response, then sends CMD1 and waits. I'm also
waiting 250ms for the contacts to settle after the card-in switch (actually a
pin on the MMC slot that's grounded by the card) goes to the 'card is in the
slot' state.

It might be worth trying to do more initialisation clock cycles before sending
the CMD0 -- my code appears to be doing 160 bits (20x 0xFF bytes).

Thanks.
--
Phil.                         |  (\_/)  This is Bunny. Copy and paste Bunny
TakeThisOuTpiclistEraseMEspamspam_OUTphilpem.me.uk         | (='.'=) into your signature to help him gain
http://www.philpem.me.uk/     | (")_(") world domination.


'[BUY] Help with microSD or SD card interfacing'
2007\04\01@131314 by William Chops Westfield
face picon face

On Mar 30, 2007, at 9:42 AM, James Newtons Massmind wrote:

> I'm quite a few hours into attempting to connect a microSD (aka
> TransFLASH)
> card to an MSP430F1611 and I'll be damned if I can get any response
> back
> from the card.
>
There are apparently some SD cards that don't support SPI mode access
(despite
that fact that they're supposed to by the spec (although I don't know
if that's
the micro-sd spec, or just for full size.))  This is apparently
somewhat related
to size of card; few 2G SD cards are likely to work in SPI mode, SOME
1G cards,
and MOST 512M and smaller cards...

BillW

2007\04\01@222048 by Harold Hallikainen

face
flavicon
face
Interesting! Each time we get a batch of cards from a new supplier, we
test it in our product
(http://www.dovesystems.com/index.php?page=shop.flypage&product_id=56&category_id=097cd77791c8f09d2dd8cfd880c21d0e&option=com_phpshop)
to make sure it works! So far, they all have. Our storage requirements are
minimal, so we've been buing stuff in the 32M area. I've tested up to 1G
and everything has worked so far...

Harold




{Quote hidden}

> -

2007\04\01@230443 by William Chops Westfield

face picon face

On Apr 1, 2007, at 7:20 PM, Harold Hallikainen wrote:

> Interesting! Each time we get a batch of cards from a new supplier, we
> test it in our product ... to make sure it works! So far, they all
> have.

Maybe your product is better implemented than the "reference platform" I
was basing my claim upon.  All SD cards are SUPPOSED to support SPI/MMC
mode, but when a commercial product doesn't work with some cards, one
tends to suspect the card rather than the product for some reason.  It'd
be interesting to understand the subtleties that lead one type of card
to
fail and another succeed using the same reader-side code...

BillW

2007\04\02@012959 by WH Tan

flavicon
face
James,

This has been released for some time, but I haven't gone through the detail
of it yet...  but I think it might be helpful to you.

http://www.microchip.com.tw/modules/mydownloads/visit.php?cid=1&lid=69

It's a link to get a zip file, which contains some material + code for CF
and SD card. If I recall correctly, the file system is FAT16.


Best regards,

WH Tan





> {Original Message removed}

2007\04\05@170131 by James Newton, Host

face picon face
> From: James Newton
> Sent: 2007 Mar 30, Fri 09:43
>
> I'm quite a few hours into attempting to connect a microSD
> (aka TransFLASH) card to an MSP430F1611 and I'll be damned if
> I can get any response back from the card.
>
> I've read the datasheets, I've read the many available web
> pages on the subject, I've checked, re-checked, double
> checked and had others check the connections, and I'm looking
> at the signals I'm putting out on a logic analyzer and they
> are dead on exactly what is called for. And there is NO
> response from x4 cards.


I'm going to do what is good for the soul here and admit what the actual
problem turned out to be. The spec calls for 4 bytes of argument to be sent
between the command and the CRC. I was sending 3 bytes.

I'm not sure how many times I checked the analyzer display against the spec,
but it must have been 50 or more times. Didn't see that (obvious) difference
every single time. Another guy looked at it and said "hey, doesn't that say
4 bytes? This looks like 3 to me..."

Whereupon I said "No fxxking WAY!", changed the code, ran it and completely
freaked out when the card responded.

I'm not charging the client for about 2 days of otherwise billable time.
Some times I think it's a good thing I have a day job. Sigh. If it wasn't
for the fact that in the past I've pulled many a project out of the toilet
and saved more than a few other peoples bacon from the fire, I would quit
doing this sort of work.

Another point is that I have got to get a new unit that can export images of
the signals so that I can post them for other people to look at.

---
James Newton: PICList webmaster/Admin
RemoveMEjamesnewtonspamTakeThisOuTpiclist.com  1-619-652-0593 phone
http://www.piclist.com/member/JMN-EFP-786
PIC/PICList FAQ: http://www.piclist.com


2007\04\05@232354 by John Chung

picon face
James,

  Don beat yourself up over a mistake.We still want
an Admin :) I have read of a better solution in
solving  signal problems. It is under Circuit Cellar
201. Subject is Reverse-Engineered ECP Bus.

Regards,
John


--- "James Newton, Host" <jamesnewtonEraseMEspam.....piclist.com>
wrote:

{Quote hidden}

> --

2007\04\06@175139 by Sean Breheny

face picon face
James,

Please don't beat yourself up. A friend of mine and I once spent
several WEEKS trying to figure out why a processor with external
memory wasn't booting, only to find out eventually that we had an
endian problem (We referred to the two flash chips as HIGH and LOW,
and by that he meant high/low significance and I meant high/low
address. Since it was a motorola mc68302, these were not the same!).
Simply swapping the ICs caused it to boot right away.

Sean


On 4/5/07, James Newton, Host <RemoveMEjamesnewtonEraseMEspamEraseMEpiclist.com> wrote:
{Quote hidden}

> -

2007\04\10@070323 by Alan B. Pearce

face picon face
>I'm not charging the client for about 2 days of otherwise billable time.
>Some times I think it's a good thing I have a day job. Sigh. If it wasn't
>for the fact that in the past I've pulled many a project out of the toilet
>and saved more than a few other peoples bacon from the fire, I would quit
>doing this sort of work.

Sometimes yah just have to put it down to learning, don't yah ... ;)

>Another point is that I have got to get a new unit that can export images
>of the signals so that I can post them for other people to look at.

Tektronix 20xxB series, socket for USB memory stick on front panel? The
earlier 20xx series has an add-on that takes a CF card. The 30xx series use
a floppy disk, but does have better screen resolution. The 30xxB also has
Ethernet as standard I think.

More... (looser matching)
- Last day of these posts
- In 2007 , 2008 only
- Today
- New search...