EmbeddedRelated.com
Forums

SD CARDS

Started by Onestone February 8, 2012
Hi I wonder if anyone out there has an explanation for the following
problem. I am developing an SD card based application, so far not too
many problems, other than oddly lacking documentation, but I have
working code that has worked on a Kingston 2gb card and a Nokia 2Gb card
I salvaged from an old cell phone. I accidentally blew the Kingston card
when I dropped it across a 5V supply, but the nokia card has been rock
solid. Because I only had 1 2gb card I decided that until the 20+
Kingston cards I ordered arrive I would buy one locally as back up. So I
bought a 2gb SanDisk. The 2Gb limit is because a) I don't need more and
b) it lets me use FAT16 for easy download on a PC. I plugged the Sandisk
card it and don't even get a response to CMD0. Weird. Retried the Nokia
and it's perfect, Sandisk fails Nokia works. Any ideas? I'm now getting
worried that maybe the new Kingston cards won't work either, but then
the original Kingston card was a 'new' one so hopefully I'll be alright.

It seems odd that it should fail at such an early stage in the process.
I would understand if it was a 2.0 spec card and was not disliking the
lack of a CMD8 command.

Cheers

Al

Beginning Microcontrollers with the MSP430

On 02/08/2012 07:43 PM, Onestone wrote:

>The original Kingston card was a 'new' one so hopefully I'll be alright.
>
> It seems odd that it should fail at such an early stage in the process.
> I would understand if it was a 2.0 spec card and was not disliking the
> lack of a CMD8 command.
>
> Cheers
>
> Al
>

CMD0 with CS asserted is the only way to get into SPI mode. If the card
doesn't respond it might not support SPI but that seems unlikely. Did
you send the required startup clocks? Another possibility is that there
are apparently a lot of dicey (fake, counterfeit, out of spec. etc.)
cards on the market.

I have run into cards that do not comply with the spec. Oddly, they were
Kingston. Instead of echoing the check pattern in CMD8, they sent a
fixed value of 0xAA. Which is the recommended check pattern but simply
assuming it doesn't help at all.

Recently I have been working on code for an SDIO interface and these
Kingston cards failed there as well but at a different step.
--
David W. Schultz
http://home.earthlink.net/~david.schultz
"Put down that pickle!"
Onestone wrote:
> Hi I wonder if anyone out there has an explanation for the following
> problem...

I might have a reasonable guess. When I worked the sd card, (pretty sure
it was a Kingston), it worked fine without pull ups on the unused pins.
But F. Foust said in his paper that the pins 'must' be pulled up with
50k resistors. And I think he was using a sandisk card. Do you have pull
ups?

Best, Dan.

--
Newspapers are unable, seemingly to discriminate between a bicycle accident and the collapse of civilization.
George Bernard Shaw

Hi David. Thanks for the reply.

basically the system runs fine with my Nokia card. I t was running Ok
with a Kingston card too, but i managed to blow that. I finsihed the
basic code for file management, FAT handling etc and decided that I
should test it with another brand of card. Bought a 2gb Sandisk and it
didn't work. I've since chekced it with several other cards, but all >
2Gb and none work bar the Nokia (and the original Kingston. So yes the
init sequence is working, CS is being asserted, it is from a very
reputable source so I believe it is a genuine card. I'm slightly
confused for now.

cheers

Al

On 9/02/2012 12:41 PM, David W. Schultz wrote:
> On 02/08/2012 07:43 PM, Onestone wrote:
>
>> The original Kingston card was a 'new' one so hopefully I'll be alright.
>>
>> It seems odd that it should fail at such an early stage in the process.
>> I would understand if it was a 2.0 spec card and was not disliking the
>> lack of a CMD8 command.
>>
>> Cheers
>>
>> Al
>>
> CMD0 with CS asserted is the only way to get into SPI mode. If the card
> doesn't respond it might not support SPI but that seems unlikely. Did
> you send the required startup clocks? Another possibility is that there
> are apparently a lot of dicey (fake, counterfeit, out of spec. etc.)
> cards on the market.
>
> I have run into cards that do not comply with the spec. Oddly, they were
> Kingston. Instead of echoing the check pattern in CMD8, they sent a
> fixed value of 0xAA. Which is the recommended check pattern but simply
> assuming it doesn't help at all.
>
> Recently I have been working on code for an SDIO interface and these
> Kingston cards failed there as well but at a different step.
On 02/08/2012 09:03 PM, Onestone wrote:
> Hi David. Thanks for the reply.
>
> basically the system runs fine with my Nokia card. I t was running Ok
> with a Kingston card too, but i managed to blow that. I finsihed the
> basic code for file management, FAT handling etc and decided that I
> should test it with another brand of card. Bought a 2gb Sandisk and it
> didn't work. I've since chekced it with several other cards, but all >
> 2Gb and none work bar the Nokia (and the original Kingston. So yes the
> init sequence is working, CS is being asserted, it is from a very
> reputable source so I believe it is a genuine card. I'm slightly
> confused for now.
>
> cheers
>
> Al

It may or may not help but an early version of my FAT16 and SD/SPI code
is here:

http://home.earthlink.net/~schultdw/logOmatic/

While that version is for an ARM target I have ported it to the MSP430.

I was frequently confused when I wrote it. :-)
--
David W. Schultz
http://home.earthlink.net/~david.schultz
"Put down that pickle!"
Hi Dan, and thanks for replying. I have pull ups on the 2 'RSV' lines,
which, according to the reference I have is the requirement for SPI
mode, but information seems a little sparse. I have only been able to
get the simplified version of the spec and that doesn't actually show
the physcial layout. I have interface diagrams for several other brands
of cards and they all show no resistors (contrary to the Sd spec) I
quote the following:-

floating when no card is inserted or when all card drivers are in a
high-impedance mode.
The host shall pull-up all DAT0-3 lines by RDAT, even if the host uses
SD Memory Card as 1 bit mode-only in SD mode. Also, the host shall
pull-up all "RSV" lines in SPI mode, even though they are not used.

I am using Micro SD, and the above is from the data sheet for a MaxNova
card. Since the two RSV lines are DAT1 and DAT2 in SD mode I have taken
this to mean that these are the only lines that need to be pulled up
since the CMD line becomes MOSI, DAT3 becomes /CS and DAT0 becomes MISO.

I am beginning to suspect that you may be onto the issue though. Damn
it!! Any idea where I can get the full spec data sheet from without
having to buy it?

Cheers
Al

On 9/02/2012 1:28 PM, Dan Bloomquist wrote:
> Onestone wrote:
>> Hi I wonder if anyone out there has an explanation for the following
>> problem...
> I might have a reasonable guess. When I worked the sd card, (pretty sure
> it was a Kingston), it worked fine without pull ups on the unused pins.
> But F. Foust said in his paper that the pins 'must' be pulled up with
> 50k resistors. And I think he was using a sandisk card. Do you have pull
> ups?
>
> Best, Dan.
>


Hi David, I have frequently been confused through much of this 'trip'.
My code is in asm (as always) I have found that the documentation is
hard to find, and often incomplete. For example when you read data from
the various on board registers etc much of it is in little endian
format, yet you have to send the address to9 the card in MSB_LSB order
in the arguments. Also the data I have discusses only SECTORS, as the
addressing unit, then suddenly switches to BLOCKs without an
explanation, but nowhere did I find anything that even remotely
suggested that you needed to supply a linear byte sized address. I
looked at the Foust and Evans stuff, but discarded most of it as I felt
it was really badly written code wise. What is making thinsg even harder
is that I'm being forced to implement this stage of things on a 2274
with no DMA and just 1K of RAM, but need to provide FAT16 and a data
throughput of close to 4Mbps

the code is working right now on a NOKIA 2Gb card, it just won't work on
the other cards I have to hand. I'm thinking that Dan hit it on the head
and that i need to have pull ups where I haven't. I only have them on
the two named RSV lines for Micro SD SPI mode.

Cheers

Al

On 9/02/2012 1:46 PM, David W. Schultz wrote:
> On 02/08/2012 09:03 PM, Onestone wrote:
>> Hi David. Thanks for the reply.
>>
>> basically the system runs fine with my Nokia card. I t was running Ok
>> with a Kingston card too, but i managed to blow that. I finsihed the
>> basic code for file management, FAT handling etc and decided that I
>> should test it with another brand of card. Bought a 2gb Sandisk and it
>> didn't work. I've since chekced it with several other cards, but all>
>> 2Gb and none work bar the Nokia (and the original Kingston. So yes the
>> init sequence is working, CS is being asserted, it is from a very
>> reputable source so I believe it is a genuine card. I'm slightly
>> confused for now.
>>
>> cheers
>>
>> Al
> It may or may not help but an early version of my FAT16 and SD/SPI code
> is here:
>
> http://home.earthlink.net/~schultdw/logOmatic/
>
> While that version is for an ARM target I have ported it to the MSP430.
>
> I was frequently confused when I wrote it. :-)
On 02/08/2012 09:29 PM, Onestone wrote:
> the code is working right now on a NOKIA 2Gb card, it just won't work on
> the other cards I have to hand. I'm thinking that Dan hit it on the head
> and that i need to have pull ups where I haven't. I only have them on
> the two named RSV lines for Micro SD SPI mode.
>
> Cheers
>
> Al
>

The cards are supposed to start with the DO pin in open drain mode. This
is the reason for the reduced clock rate during initialization. That is
the only pull up I provided on the interface between the MSP430 and
microSD card.

Once init is done that pin switches to push-pull and you can crank up
the clock.

--
David W. Schultz
http://home.earthlink.net/~david.schultz
"Put down that pickle!"
Hi David. I have the clock cranking up to 8MHz after initialisation, but
don't have a pull up on D0, only the 2 pins labelled as RSV. maybe that
is an issue. Damned tiny to solder a pull up there in retrospect though
when I'm using a microSD and push-pull style holder. Add to that bad
coordination and shakes due to a buggered spine and it may be time to
build a new board! Thanks for the insights so far.

cheers

Al

On 9/02/2012 3:26 PM, David W. Schultz wrote:
> On 02/08/2012 09:29 PM, Onestone wrote:
>> the code is working right now on a NOKIA 2Gb card, it just won't work on
>> the other cards I have to hand. I'm thinking that Dan hit it on the head
>> and that i need to have pull ups where I haven't. I only have them on
>> the two named RSV lines for Micro SD SPI mode.
>>
>> Cheers
>>
>> Al
>>
> The cards are supposed to start with the DO pin in open drain mode. This
> is the reason for the reduced clock rate during initialization. That is
> the only pull up I provided on the interface between the MSP430 and
> microSD card.
>
> Once init is done that pin switches to push-pull and you can crank up
> the clock.
>
Al,

you maybe have to wait some time until CMD0 is ready. I send the CMD0 command
several times until it is recognized by the card - timeout 1 second.
It is important that at least DAT3 and CMD (Pins 1 and 2) are at high level
during power up of the card. However I have 330k Pullups on DAT0, DAT3 and
CMD. DAT1 and DAT2 are not connected at all. I reduced clock speed to 100kHz
during the initial commands also. Reason is during the initial CMD0 the cards
responds with open drain outputs only. After init is completed, the card is
switching to Push-Pull outputs and can handle 20MHz or more.

M.
Onestone :

> Hi Dan, and thanks for replying. I have pull ups on the 2 'RSV' lines,
> which, according to the reference I have is the requirement for SPI
> mode, but information seems a little sparse. I have only been able to
> get the simplified version of the spec and that doesn't actually show
> the physcial layout. I have interface diagrams for several other brands
> of cards and they all show no resistors (contrary to the Sd spec) I
> quote the following:-
>
> floating when no card is inserted or when all card drivers are in a
> high-impedance mode.
> The host shall pull-up all DAT0-3 lines by RDAT, even if the host uses
> SD Memory Card as 1 bit mode-only in SD mode. Also, the host shall
> pull-up all "RSV" lines in SPI mode, even though they are not used.
>
> I am using Micro SD, and the above is from the data sheet for a MaxNova
> card. Since the two RSV lines are DAT1 and DAT2 in SD mode I have taken
> this to mean that these are the only lines that need to be pulled up
> since the CMD line becomes MOSI, DAT3 becomes /CS and DAT0 becomes MISO.
>
> I am beginning to suspect that you may be onto the issue though. Damn
> it!! Any idea where I can get the full spec data sheet from without
> having to buy it?
>
> Cheers
> Al
>
> On 9/02/2012 1:28 PM, Dan Bloomquist wrote:
>> Onestone wrote:
>>> Hi I wonder if anyone out there has an explanation for the following
>>> problem...
>> I might have a reasonable guess. When I worked the sd card, (pretty sure
>> it was a Kingston), it worked fine without pull ups on the unused pins.
>> But F. Foust said in his paper that the pins 'must' be pulled up with
>> 50k resistors. And I think he was using a sandisk card. Do you have pull
>> ups?
>>
>> Best, Dan.
>>