AnsweredAssumed Answered

sdcard write error

Question asked by jack erison on Apr 22, 2014

Hi everyone,

     I have a trouble about sdcard writing in MQX4.1,and my platform is k60d100m.I write somedata to a csv file, but sometimes later the file can't be opended, and the file pointer is NULL.

When I inserted the sdcard to my computer,I foud the file is error, it can't be deleted or copied.The only soultion is delete the via the shell command of my board.So it can write again,but it will occuer again.

I used the "C:\Freescale\Freescale_MQX_4_1\mfs\examples\sdcard\build\iar\mfs_sdcard_twrk60d100m" project to test the sdcard.Here is my code.


int32_t Shell_command_filetest(int32_t argc, char *argv[])


    MQX_FILE_PTR    fd_ptr;

    int32_t error_code;

    int i, j;


    fd_ptr = fopen("a:/my1.csv", "a");


    if(NULL == fd_ptr)


        printf("open a:/my1.csv error!\n");




    for( i =0; i< 3000; i++)


      //for(j=0; j<100; j++)


        fputc((0x30+j%10), fd_ptr);        //

        fputc(0x09, fd_ptr);



      fputc(0x0D, fd_ptr);




    /* Close the file: */

    error_code = fclose(fd_ptr);



  return 0;





* Function Name  : sdcard_task

* Returned Value : void

* Comments       :



void sdcard_task(uint32_t temp)


    (void)          temp; /* suppress 'unused variable' warning */



    char **argv;



        if(true ==sdcard_check())





        _time_delay (100);




The attachment is my whole test code.

Original Attachment has been moved to: