Hi Arth Shah,
Comment the Fatfs code, just leave MMCinit(),
Main code like this:
int main(void)
{
char ch;
unsigned int i,j;
FATFS fs;
FRESULT fr;
FIL fil;
UINT bw;
char file_name1[12]="Test.csv";
char file_name2[12]="Test.txt";
/* Init board hardware. */
BOARD_InitPins();
BOARD_BootClockRUN();
BOARD_InitDebugConsole();
PRINTF("hello world.\r\n");
spiInit(Master);
MMCInit();
/*
fr= f_mount(&fs,file_name1,0);
if(fr)
{
PRINTF("\nError mounting file system\r\n");
for(;;){}
}
fr = f_open(&fil, file_name1, FA_WRITE | FA_OPEN_ALWAYS);//н¨csvÎļþ
if(fr)
{
PRINTF("\nError opening text file\r\n");
for(;;){}
}
fr = f_write(&fil, "Test1 ,Test2 ,Test3 ,Test4 \r\n", 29, &bw); //±íÍ·
if(fr)
{
PRINTF("\nError write text file\r\n");
for(;;){}
}
fr = f_close(&fil);
if(fr)
{
PRINTF("\nError close text file\r\n");
for(;;){}
}
fr= f_mount(&fs,file_name2,0);
if(fr)
{
PRINTF("\nError mounting file system\r\n");
for(;;){}
}
fr = f_open(&fil, file_name2, FA_WRITE | FA_OPEN_ALWAYS);//н¨txtÎļþ
if(fr)
{
PRINTF("\nError opening text file\r\n");
for(;;){}
}
fr = f_write(&fil, "Test1 ,Test2 ,Test3 ,Test4 \r\n", 29, &bw); //±íÍ·
if(fr)
{
PRINTF("\nError write text file\r\n");
for(;;){}
}
fr = f_close(&fil);
if(fr)
{
PRINTF("\nError close text file\r\n");
for(;;){}
}
*/
while (1)
{
//ch = GETCHAR();
// PUTCHAR(ch);
for(i=0;i<10;i++) for(j=0;j<65535;j++);
printf("\ntest_sd\n");//
}
}
Debug again, where you stop?
This is my debug picture:

You can see, even I didn't insert the SD card, the SPI also can send data.
But take care, if your SD card can't give feedback. It may caused by the SD card, this code just for SD2.0 card.
You can debug the MMCInit, and check where it can run, whether CMD0 have feedback.
Besides, also refer to my post, check your SD card hardware circuit.
Have a great day,
Kerry
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------