3

I am using an STM32 micrcocontroller to interface an SD card memory using the SPI peripheral. I have done tests with 2Gb , 4Gb , 8Gb and 16Gb SanDisk cards. When I perform a reset with the 2Gb and 8Gb cards , nothing happens and I keep going with my tests. However, with 4Gb and 16Gb , once the reset is performed intialization fails . In fact , at the first insert in the SD slot , these cards are quite good initialized but one I perform the reset it does'nt pass.

When I tried to debug this problem, I discovered that when dealing a reset the response to command CMD0 is wrong . I get 0x00 instead of 0x01 which means that my card is not in Idle state.

I supposed that the problem is due to timing issues with the CS line. So , I tried to de-assert the CS before sending the CMD0 command and sending dummy bytes in order to make the card waiting 8 cloks period. Then , I send CMD0 and I assert the CS line to High. ( see below )

SD_IO_CSState(0);
SD_IO_WriteByte(SD_DUMMY_BYTE);
response = SD_SendCmd(SD_CMD_GO_IDLE_STATE, 0, 0x95, SD_ANSWER_R1_EXPECTED);
SD_IO_CSState(1);
SD_IO_WriteByte(SD_DUMMY_BYTE);

Using this solution , the Initialization passes after few reset tests. But , at any moment it can fails which is not the case with the 2Gb and 8Gb cards.

Any suggestions to solve it ??

1
  • I noticed that 32 GB microSD card from SanDisk doesn't respond to CMD0 properly until it finishes it's data stream in response to commands "read block" or "write block". I receive expected 0x01 after CMD0 only when it is sent after last byte from SD-card. Don't have such problems with 8 GB from Transcend (full-size card). Apr 20, 2021 at 18:30

1 Answer 1

0

I am also facing the exact same issue with my 24 GB SanDisk SD Card. What I have learnt is that perhaps SD Cards once initialized in SPI mode don't accept CMD0 again (which is the software reset command!), the only method to bring them back to initial state is to perform their power cycle.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.