From: Murray R. Van Luyn on
Hi Peter,

If I misunderstand you correctly this sequence is wrong:

-------------------------------------------------------------------------------

/* Send CMD55 to indicate that next command is application specific */
/* MMC cards do not respond to this command */
cmd[0] = SD_CARD_CMD55;
cmd[5] = SD_CARD_CMD55_CRC;
retries = 0;
while(sd_card_write_command(cmd) != SD_CARD_NO_ERROR)
{
if(retries++ > 500)
{
SD_CARD_CS = 1; // Disable SD card
return(SD_CARD_NOT_SD); // No response - not an SD card
}
}

/* Send ACMD41 SEND_OP_COND command */
cmd[0] = SD_CARD_ACMD41;
cmd[5] = SD_CARD_ACMD41_CRC;
retries = 0;
while(sd_card_write_command(cmd) != SD_CARD_NO_ERROR)
{
if(retries++ > 500)
{
SD_CARD_CS = 1; // Disable SD card
return(SD_CARD_ERROR); // No response
}
}
-------------------------------------------------------------------------------

What is the CMD55+CMD41 combo if it's not CMD55 (6 bytes beginning 0x37)
followed by ACMD41 (6 bytes beginning 0x29)?

Regards,
Murray R. Van Luyn.

"Peter Jakacki" <peterjakacki(a)gmail.com> wrote in message
news:2ENYk.2333$Et1.1594(a)news-server.bigpond.net.au...
> Murray R. Van Luyn wrote:
>> It seems that I'm going to get a 0x01 response no matter how many times I
>> issue CMD0.
>>
>> Also, it seems that I'm going to get an invalid response (0xFF) no matter
>> how many times I then issue CMD55.
>
> Yes, of course, but read my previous post. BTW, 01 is the correct response
> for CMD0 then you move on to Acmd41 not CMD55 .
>
> *Peter*


From: Peter Jakacki on
Uncluttering it and taking it from the top:

Quote from SANDISK Product Manual SD Card V2.2 final
- Section 3.4.1 Power Up

"ACMD41 is a special synchronization command used to negotiate the
operation voltage range and to poll the cards until they are out of
their power-up sequence. Besides the operation voltage profile of the
cards, the response to ACMD41 contains a busy flag, indicating that the
card is still working on its power-up procedure and is not ready for
identification. This bit informs the host that the card is not ready.
The host has to wait (and continue to poll the cards, each one on his
turn) until this bit is cleared. The maximum period of power up
procedure of single card shall not exceed one second."

All ACMDs are just like a normal command except they are preceded by a
CMD55. This is a sequence that only SD cards recognize and is not a
feature of MMC just in case you are following MMC specs or some sample code.

ACMD41 for instance is equivalent to issuing CMD55, discard the result,
issue CMD41 and return with that result.

BTW, you can ignore CRC as it is not needed in SPI mode, you only need
it before you first switch to SPI mode so just use the value 0x95 as the
CRC in each command (read the specs).

*Peter*




Murray R. Van Luyn wrote:
> Hi Peter,
>
> If I misunderstand you correctly this sequence is wrong:
>
> -------------------------------------------------------------------------------
>
> /* Send CMD55 to indicate that next command is application specific */
> /* MMC cards do not respond to this command */
> cmd[0] = SD_CARD_CMD55;
> cmd[5] = SD_CARD_CMD55_CRC;
> retries = 0;
> while(sd_card_write_command(cmd) != SD_CARD_NO_ERROR)
> {
> if(retries++ > 500)
> {
> SD_CARD_CS = 1; // Disable SD card
> return(SD_CARD_NOT_SD); // No response - not an SD card
> }
> }
>
> /* Send ACMD41 SEND_OP_COND command */
> cmd[0] = SD_CARD_ACMD41;
> cmd[5] = SD_CARD_ACMD41_CRC;
> retries = 0;
> while(sd_card_write_command(cmd) != SD_CARD_NO_ERROR)
> {
> if(retries++ > 500)
> {
> SD_CARD_CS = 1; // Disable SD card
> return(SD_CARD_ERROR); // No response
> }
> }
> -------------------------------------------------------------------------------
>
> What is the CMD55+CMD41 combo if it's not CMD55 (6 bytes beginning 0x37)
> followed by ACMD41 (6 bytes beginning 0x29)?
>
> Regards,
> Murray R. Van Luyn.
>
> "Peter Jakacki" <peterjakacki(a)gmail.com> wrote in message
> news:2ENYk.2333$Et1.1594(a)news-server.bigpond.net.au...
>> Murray R. Van Luyn wrote:
>>> It seems that I'm going to get a 0x01 response no matter how many times I
>>> issue CMD0.
>>>
>>> Also, it seems that I'm going to get an invalid response (0xFF) no matter
>>> how many times I then issue CMD55.
>> Yes, of course, but read my previous post. BTW, 01 is the correct response
>> for CMD0 then you move on to Acmd41 not CMD55 .
>>
>> *Peter*
>
>
From: tporter on
On Mon, 1 Dec 2008 17:45:59 +0900, "Murray R. Van Luyn"
<NOSPAM(a)NOSPAM> wrote:

>Thanks Peter.
>
>It seems that I'm going to get a 0x01 response no matter how many times I
>issue CMD0.
>
>Also, it seems that I'm going to get an invalid response (0xFF) no matter
>how many times I then issue CMD55.
>
>Vexing!
>
>Regards,
>Murray R. Van Luyn.
>
>"Peter Jakacki" <peterjakacki(a)gmail.com> wrote in message
>news:dWMYk.2320$Et1.1805(a)news-server.bigpond.net.au...
>> Murray R. Van Luyn wrote:
>>> Hi,
>>>
>>> I'm trying to initialise a 2GB Transcend SD card with an AT89C51AC2.
>>>
>>> I send CMD0 and get a 0x01 response. It's initialising...
>>>
>>> Then I send 10 CMD55 messages and get no valid response (0xFF) each time.
>>> I don't know why I don't get a 0x01 response here until the card has
>>> finished initialising?
>>>
>>> Sound familiar to anyone?
>>
>> You send CMD0 and that's fine but you need to send ACMD41 which is
>> CMD55+CMD41 combo. I don't put a limit on the number of times I do this
>> but depend upon a timeout instead. It depends upon the card.
>>
>> *Peter*
>>
>
Typically, you issue a CMD0 20 or 30 times to reset the card (I'm not
worrying about MMC cards here). Then you can follow w/ either a CMD8,
which distinguishes between SD +/- V2 cards, followed by the
CMD55/ACMD41 pair.

Question I have for you is. do you see the exact same behavior whether
a card is inserted or not? I have seen what looks like go_idle_state
(CMD0) succeed) followed by fails on CMD55, which turned out to be a
physical problem w/ the SD socket - broken switch or a piece of junk
wedged near the bottom.

Make sure the card is being electrically recognized before you start
worrying over the CMD returns.

Best, Tom
From: Murray R. Van Luyn on

"tporter" <tporter(a)dtool.com> wrote in message
news:hj3dj4lg1c9a62j1nor5tvfeefcr6kliu5(a)4ax.com...
> On Mon, 1 Dec 2008 17:45:59 +0900, "Murray R. Van Luyn"
> <NOSPAM(a)NOSPAM> wrote:
>
>>Thanks Peter.
>>
>>It seems that I'm going to get a 0x01 response no matter how many times I
>>issue CMD0.
>>
>>Also, it seems that I'm going to get an invalid response (0xFF) no matter
>>how many times I then issue CMD55.
>>
>>Vexing!
>>
>>Regards,
>>Murray R. Van Luyn.
>>
>>"Peter Jakacki" <peterjakacki(a)gmail.com> wrote in message
>>news:dWMYk.2320$Et1.1805(a)news-server.bigpond.net.au...
>>> Murray R. Van Luyn wrote:
>>>> Hi,
>>>>
>>>> I'm trying to initialise a 2GB Transcend SD card with an AT89C51AC2.
>>>>
>>>> I send CMD0 and get a 0x01 response. It's initialising...
>>>>
>>>> Then I send 10 CMD55 messages and get no valid response (0xFF) each
>>>> time.
>>>> I don't know why I don't get a 0x01 response here until the card has
>>>> finished initialising?
>>>>
>>>> Sound familiar to anyone?
>>>
>>> You send CMD0 and that's fine but you need to send ACMD41 which is
>>> CMD55+CMD41 combo. I don't put a limit on the number of times I do this
>>> but depend upon a timeout instead. It depends upon the card.
>>>
>>> *Peter*
>>>
>>
> Typically, you issue a CMD0 20 or 30 times to reset the card (I'm not
> worrying about MMC cards here). Then you can follow w/ either a CMD8,
> which distinguishes between SD +/- V2 cards, followed by the
> CMD55/ACMD41 pair.
>
> Question I have for you is. do you see the exact same behavior whether
> a card is inserted or not? I have seen what looks like go_idle_state
> (CMD0) succeed) followed by fails on CMD55, which turned out to be a
> physical problem w/ the SD socket - broken switch or a piece of junk
> wedged near the bottom.
>
> Make sure the card is being electrically recognized before you start
> worrying over the CMD returns.
>
> Best, Tom

Hi Tom,

Well the electrical interface is now 100% correct, thanks to your advice.
I'm still getting no further than CMD8. There's still no reply from the SD
card no matter how many times it's polled. As far as I'm concerned the
signals being issued to the SD card are okay. I'm stumped!

Regards,
Murray R. Van Luyn.


From: Peter Jakacki on
I have had problems with 2G cards which I suspect might not be SPI
compatible, only SD compatible. However we could all be playing a never
ending guessing game unless we have the same details you have such as
the schematic and code and details of the exact card.

Of course you should be trying other cards which I assume you have done,
it's one of the very first rules of troubleshooting to eliminate various
factors and home in on the cause. Try a 1G card or smaller.

*Peter*

Murray R. Van Luyn wrote:
> Hi Tom,
>
> Well the electrical interface is now 100% correct, thanks to your advice.
> I'm still getting no further than CMD8. There's still no reply from the SD
> card no matter how many times it's polled. As far as I'm concerned the
> signals being issued to the SD card are okay. I'm stumped!