I would think power supply issues like ripples, noises or oscillations are the first thing one would check if the circuit is behaving intermittently.
When you send CMD0 command to place the SD card into SPI mode, you have to make sure it is placed in that mode by checking for the 0x01 response.
At end of each command, dis-select SD Card and send one more 0xFF (sends 8 more clock pulses). These can actually be done in either order.
Then you check for completion of initialization of SD card using the CMD1 command, for a 0x01(still busy) response or a 0x00(done) response. Wait until you get a 0x00 response. This might take up to a second for very large size SD card.
Now send other commands.
Yes if you did'nt enabeled internal, i guess. It does not harm to check if it works.
A reference design. https://www.brushelectronics.com/index.php?page=projects
After supply voltage reached 2.2 volts, wait for a millisecond at least. Set SPI clock rate between 100kHz and 400kHz. Set DI and CS high and apply 74 or more clock pulses to SCLK. The card will enter its native operating mode and go ready to accept native commands.
Send a CMD0 with CS low to reset the card. The card samples CS signal on a CMD0 is received successfully. If the CS signal is low, the card enters SPI mode and responds R1 with In Idle State bit (0x01). Since the CMD0 must be sent as a native command, the CRC field must have a valid value. When once the card enters SPI mode, the CRC feature is disabled and the CRC is not checked by the card so that command transmission routine can be written with the hardcorded CRC value that valid for only CMD0 and CMD8 with the argument of zero. The CRC feature can also be switched with CMD59. https://ww1.microchip.com/downloads/en/AppNotes/01045b.pdf https://www.microchip.com/forums/tm.aspx?m=623061&high=spi+pullup+resistor
If you bought an SD card, chances are its already pre-formatted with a FAT filesystem. However you may have problems with how the factory formats the card, or if its an old card it needs to be reformatted.
The memory cards are initially patitioned and formatted to align the allocation unit to the erase block. When re-patition or re-format the memory card with a device that not compliant to MMC/SDC (this is just a PC) with no care, the optimization will be broken and the write performance might be lost. I tried to re-format 512MB SDC in FAT32 with a PC, the write performance measured in file copy was lowerd to one several. Therefore the re-formatting the card should be done with MMC/SDC compliant equipments rather than PC.
use the official SD card formatter utility - written by the SD association it solves many problems that come with bad formatting!
**broken link removed**
Even though you can could use your SD card 'raw' - its most convenient to format the card to a filesystem.
the card must be formatted FAT16 or FAT32. Some only allow one or the other. It depends on your compiler and libraries available. FAT or FAT16 is popular.
I am using MicroSD card 2GB which comes with nokia mobile and i formatted that card using default FAT file system. I have looked on internet for Specification Sheet of microsd card but could find one. I want to know the timing diagram of SCK, MISO and MOSI signals and also whether microsd respond during each bit transfer i.e whether i have to make SMP bit 1 or 0.