Micro-SD card initialisation-problem

Hello all,

I've connected a Micro-SD card to my printerport (using very simple 5v to

3v voltage-step-down by three diodes and a resistor, signal step-down by a 1k8, 3k3 resistor combination), and am attempting to read from it.

The problem is that I can't seemto be able to get past the initialisation-process. I can send a CMD0 to the card, and a CMD8 too (multiple times), but whenever I try to enter a CMD1 or ACMD41 (CMD55 followed by a CMD41) loop I can write the commands once, sometimes 5 times and than the card stops responding (does not return any status-byte in about a two seconds). It does however respond to a re-start though (I can than again write a CMD0 and get a response).

I've currently tried numerous things and read about 8 to 12 different documents (apart from a number of PDFs) that have to do with communicating with a MicroSD card, but have not found any indication to what the cause of the above problem might be.

In short : if anyone knows what I should be doing to solve it I would be gratefull.

Regards, Rudy Wieser

Reply to
R.Wieser
Loading thread data ...

If the micro-sd card is like the sd card, are you using the SPI mode, or are you using all the bits? If you are using the SPI mode, I've found that one of the first hurdles is always making sure that the card has gone into the SPI mode properly.

I think you have to do that before you can start sending commands.

If you are getting into the SPI mode and getting good responses to the first commands, I would next try a different brand of card. I've found that all SD cards are not created equal.

Mark Borgerson

Reply to
Mark Borgerson

Ditto that. I'd suggest you use a well know brand, eg SanDisk, and a mid-range capacity, say 256MB-1GB, for your initial testing.

Regards,

--
Mark McDougall, Engineer
Virtual Logic Pty Ltd, 
21-25 King St, Rockdale, 2216
Ph: +612-9599-3255 Fax: +612-9599-3266
Reply to
Mark McDougall

Hello Mark,

I'm sorry, I should have mentioned that. I'm using SPI mode.

I thought that being able to send, for example, a CMD8 and receiving its response would be proof of that ? If not, how can I check (none of the documents I've found mentiones it) ?

I've currently got two different brand 2GByte cards, one of them being a Sandisk. Curently all my tests where with the other (cheaper) one. I'll try the Sandisk.

A question though : I would (ofcourse) be able to access both/any cards. Is there any generic code known that will service most-of-not-all cards ? If so, where can I find it ?

Regards, Rudy Wieser

Mark Borgerson schreef in berichtnieuws snipped-for-privacy@newsgroups.comcast.net...

to

a

times

about

than

communicating

of

Reply to
R.Wieser

Hello Mark,

Hmmm ... I've got two cards, one of them a Sandisk, but they both are

2GByte. I'll have to see if I can find/buy a smaller card somewhere.

Question: what stops the 2GB cards from responding as described in the documents ? And I would like to be able to eventually access both cards, do you know any things I can try ?

Regards, Rudy Wieser

Mark McDougall schreef >

Reply to
R.Wieser

Those resistor values are much too high to give clean edges on the clock input of the SD-card. A slow edge will cause noise glitches in the clock signal. You really should use proper levelshifters, or much lower (about

10x) resistor values. At least for the clock. And VERY short lines between buffer and the card clock input.

Arie de Muynck

Reply to
Arie

Hello Arie,

I got those resistor-values off the Web actually, together with a "it works for me" assurance.

Allso, making those resistors 10 times lower would mean you would actually be drawing current from the printer-port, which (ofcourse) allso has a resistor in its high-level output circuit.

That would mean two things : to many ports all sourcing a current of about

10 mili-amps could heat-up the driver-chip (controller nowerdays) quite nicely, and would allso bring the voltage-drop over the internal resistor into play.

Although the signals do show a few spikes here-and-there (I did put a scope on the signals) its not as bad as the chips own output-signal. :-)

:-) That was what I was thinking to, until I saw the clean signals on the scope (currently I've got a meter-and-a-half printer-cable betweenthe PC and the sd-card).

Allso: I currently got one of the two MicroSD cards to work : the Sandisk one (the other still refuses to initialize). I've just my first sectors worth of data (the MBR, which seems to be quite empty apart from the partition-table).

I'll first see if I can get the SanDisk card to do what I want, and than try to figure out why the other card does not want to work. I'll maybe even put some line-drivers to the signals (both ways) to see if it changes anything. But as I allready mentioned, I *can* write commands to the (stubborn) card (CMD58 for example) and read the replies. Even multiple times in quick succession.

Thanks for your suggestion though.

Regards, Rudy Wieser

Arie schreef in berichtnieuws

4880c1a7$0$14354$ snipped-for-privacy@news.xsall.nl...

to

a
Reply to
R.Wieser

Depends on the input capacitance of the card, cable length, etc... Someone might have been lucky.

Yes. that's why I always use buffers - or a spec'ed driver and short connections.

Clock edges are most important - rise and fall times must be within spec, and the data / cmd lines stable around them. Or the card must use schmitttrigger inputs on the clock. I'm not sure the spec requires that.

Without reflections? Or are you using a 10 MHz scope? The card allows up to

25 MHz clock, normally that means edges should be < 5 ns rise/fall time. You cannot see noise / glitches on a low-bandwidth scope.

Success!

Arie de Muynck

Reply to
Arie

Hello Arie,

Ofcourse. That is why I checked with the scope when the card refused to initialize. Just to make sure.

If nothing else works I'll surely try it. Currently the setup is acceptable to the SanDisk card.

But ... The "bad" card only "gives up" after a number of times (3 to 10 when using CMD1), never at the first time (and that is after the CMD0 has been accepted ofcourse). That seems to indicate that the communication is o.k..

The cards SPI speed is defined as 400 KHz max, and my scope can handle 80 MHz. I think thats enough to be able to see dirty signals

Regards, Rudy Wieser

Arie schreef in berichtnieuws

4880ee16$0$14348$ snipped-for-privacy@news.xsall.nl...

actually

about

resistor

the

to

You

Sandisk

card

Reply to
R.Wieser

Rudy,

I don't know if you are doing this to interface to an embedded system or not, but this is an off the shelf application, that has the hard work done at a cost:

formatting link

Cheers Don...

--
Don McKenzie

Site Map:            http://www.dontronics.com/sitemap
E-Mail Contact Page: http://www.dontronics.com/email

Xbee Wireless Modules, and low cost Interface Boards.
http://www.dontronics-shop.com/xbee-boards.html
Reply to
Don McKenzie

There is a difference between clock speed and edge rate. The logic inside the SD card can be sensitive to a glitch that is only 1 ns wide which would not show on your scope. Further, if the clock edge is slow, when it crosses the threshold of the input, the logic inside the SD card will put noise on the ground called ground bounce. This can make the input appear to return across the threshold and back again giving two transitions instead of just one. You will not see any of this on an 80 MHz scope and may not see it on a much faster scope since everything other than the slow edge rate is happening inside the SD card.

I know the SD card is not a high speed device with hugely fast edge rates, but the same things happen in slow devices, just to a lesser degree. When you use a slow clock edge it become sensitive to even a slight amount of ground bounce or other noise.

Rick

Reply to
rickman

Hello Don,

In that case I can use my 36-in-1 card-reading/writing USB-stick. :-)

But yes, the idea is to hook it up to an Atmel so I can retrieve, from the card, some voice-files (adpcm, pre-loaded onto it by a PC) to replay.

I could buy me a solution like you linked to, but I'm a bit of a hobbyist and would like to be able to and having fun trying to do it myself.

Thanks for the link though.

Regards, Rudy Wieser

D> > Hello all,

to

a

formatting link

-module.html

Reply to
R.Wieser

Hello rickman,

You've described a problem that I can't see and can't check for. What am I supposed to do with it ? Give up ? :-\

Regards, Rudy Wieser

rickman schreef > > Hello Arie,

acceptable

has

is

80
Reply to
R.Wieser

Do a differential diagnosis: hook up a schmittrigger buffer in the clock line, very close to the card, and see if it makes a difference. If it does, the clock edge is a problem, else not. Also keep the GND and VCC connection between card and buffer short, and the buffer (and card!!!) supply lines well decoupled: 100 nF should do, but check for VCC noise with your scope. And yes, an 80 MHz scope is enough.

Arie de Muynck

Reply to
Arie

Please do not top-post. Your answer belongs after (or intermixed with) the quoted material to which you reply, after snipping all irrelevant material. See the following links:

(taming google) (newusers)

--
 [mail]: Chuck F (cbfalconer at maineline dot net) 
 [page]: 
            Try the download section.
Reply to
CBFalconer

R.Wieser schreef in berichtnieuws

487f9cf0$0$14357$ snipped-for-privacy@news.xsall.nl...

to

The cause of the problem was, looking back, a simple one : the power-supply (the above-mentioned diode step-down) could not handle the "bad" cards current. :-|

I changed the above setup to, as a test, a standard 220 Ohm - 3v1 zener configuration, and was rewarded with *both* cards being unable to initialize. I than hooked up the scope to the chips powerline and chip-select, and noticed a power-drop (to below 2.5 volts) just before the card became un-responsive.

I had noticed it before, but did not think much of it. But inbetween I did read in the specs that the card could draw upto 60 mA, which made me reconsider the drop-down setup.

I made a simple one transistor voltage-stabelizer, and what-do-you-know, both cards initialized without a problem.

A bit of a lesson I guess : don't assume that a real-world diode behaves like the theoretical one. :-) In this case the internal resistance of the three diodes (connected from 5v to the cards powerline and than, thru a led-resistor combination, to ground (so there would allways flow a reasonable amout of current to get the diodes working) ) was enough to, at initialize-time, to make the supply-voltage drop enough to make the card got in rejection-mode ("ina" state(?) as mentioned on page 33 in the hitachi_hb28b128mm2.pdf docs)

Regards, Rudy Wieser

Reply to
R.Wieser

Hello CBFalconer,

You are welcome to your own preference. But if I have to listen to all of them I will have to post multiple versions of everything I write (one top, one bottom, one interleaved, and than the same but with the *whole* thread above or below it).

But that would only mean I would be "right" in only 1/5 of those posts, and "wrong" in all the others (and thats apart from all the troubles I would get into by "doubleposting" :-\ )

So I have choosen to create interleaved posts (using references from the origional and my responses to them), whith the origional post *as a reference* below it (so technically I'm neither a top nor bottom-poster).

Personally I dislike bottom-posting : when I open such a message I see an

*old* message instead of the new information. Very funny when multiple people respond to the same message.

Regards, Rudy Wieser

CBFalc> >

Reply to
R.Wieser

You would have had fewer pins to solder, and a better result, if you had used a 3-terminal 3.3V regulator in the first place. After many such problems, I've been keeping a tray full of various regulators handy for many years now.

In hindsight, I, and probably others here, should have caught the potential problem with power supply. I was aware that SD cards consume significant power while writing a block, and have even factored that power into battery life calculations for low-power loggers.

Mark Borgerson

Reply to
Mark Borgerson

Hello Mark,

If I had one I would probably have used it. The problem is that I'm living in a town with a single electronics-store which does not carry much "odd" components. A few 78(L)XX and 79(L)XX stabelizers is about all I can get. And alas, I'm not too happy about ordering stuff off the web ...

When I read about the card being able to draw upto 60 or even 80 mA I did not think much about it myself, cause I was just *initializing* the card, not *writing* to it, right ? Guess I thought wrong too. :-)

Regards, Rudy Wieser

Mark Borgerson schreef in berichtnieuws snipped-for-privacy@newsgroups.comcast.net...

5v

by a

power-supply

the

did

the

at

got

Reply to
R.Wieser

A matter of personal preferences, I suppose. I couldn't be a self- employed embedded systems designer without being able to order my parts from Digi-Key and others. I try to group up orders so that the $20 for 2nd day air shipment is less than 10% of the order cost. Since I build prototypes and small-volume parts with a good margin, a parts shipment cost of 10% is not an issue.

There's a little processor in there that cranks up to full speed when it receives those commands---so as to be ready for reads or writes with minimal latency.

Mark Borgerson

Reply to
Mark Borgerson

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.