Hi Ronan,
I get some progress today, I check the low level sd card driver step by step, and find a lot of bugs: SPI high and low speed, Get_Byte, SD initialization code, MMCReadSingleBlock ect. And I modify it.
Now, I have finished the detail checking and modification for MMCInit(). MMCReadSingleBlock(), MMCWriteSingleBlock(). All these function can works OK now.
I have tested it associated with the logical analyzer, check the SPI bus data, and then read and write the SD card sector, compare the SD data got by the code and the PC winhex software.
Now, post some example:
MMCInit();
for (i=0; i<512; i++)
{
myBuff1[i] = 0x30;
}
readSuccess = MMCReadSingleBlock(0X00, getBuff2);
for (i=0; i<512; i++)
{
if((i%16) ==0) printf("\n");
printf("%x ", getBuff2[i]);
}
printf("\n");
writeSuccess = MMCWriteSingleBlock(0x10, myBuff1);
readSuccess = MMCReadSingleBlock(0x10, getBuff2);
for (i=0; i<512; i++)
{
if((i%16) ==0) printf("\n");
printf("%x ", getBuff2[i]);
}
1. sector 0x00, 512Byte data
WinHex data from PC after reading the SD card

Code debug data:

2. sector 0x10, 512Byte data
WinHex data from PC after reading the SD card

Code debug data:

So, now, the key function MMCInit(). MMCReadSingleBlock(), MMCWriteSingleBlock(). can work correct now.
Because time is limited, I still need to test MMCReadMultipleBolck, MMCWriteMultipleBlock.
Actually, if all these function, and some other sd card low level code works, the fatfs will have no problem.
Tomorrow, I will check the other code step by step.
I think we are close to success now, I will try my best tomorrow, if doing well, you may get the working fatfs sd card project tomorrow.
Please keep patient again, thank you!
Have a great day,
Kerry
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------