This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

RL-Flash write/read SD card crash

I want to read/write file in SD card by RL_FLASH, I have follow code slice:

int main(void){

int count;

int ret;

FILE *fp;

char buf[12];

count = 3;

while ((ret = finit()) != 0) {

if (!(count--)) {

break;

}

}

fp = fopen ("M:\\MISC\\mmc.txt","w");

if(fp == NULL)

{

return 1;

}

else

{

strcpy(buf, "abcdefg");

ret = fwrite(buf, 1, 7, fp);

fclose(fp);

}

while(1);

}

I want to create a file and write some data in it. but it crashed when it run to "ret = fwrite(buf, 1, 7, fp);", it go to HardFault_Handler().

After run this application, I put the SD card to PC to read, found the mmc.txt was created, but it's empty. why?

0