AnsweredAssumed Answered

SD card fat read/write problem

Question asked by sudhakar p on Jul 23, 2015

Hi,

I added FATFS file system into my project (ethernet_to_serial). i am using FRDMK64F120,KDS 2.0 and KSDK1.1.0 examples project,

i tried following method. but when i open file its hanging somewhere i dnt know where its hanging.

give some solution.

 

 

 

   

        CLOCK_SYS_EnableSdhcClock(0);

 

        GPIO_DRV_Init(sdhcCdPin, NULL); //for card detection          

            config.transMode = kSdhcTransModeAdma2;      

            config.cdType = kSdhcCardDetectGpio;         

 

       

            if (SDHC_DRV_Init(BOARD_SDHC_INSTANCE, &host, &config) != kStatus_SDHC_NoError)

            {             

                 printf("FAILED SD CARD\r\n");

            }      

 

            sdcard_disk_initialize(1);

            SDCARD_DRV_Init(&host, &config);      

 

            ret=f_open(1,"read.txt",FA_READ);

            if(ret==FR_OK)

             {

                   printf("open SUCCESS\r\n");

                   printf("succ=%d",ret);

              }

               else //if(FR_DISK_ERR)

               {

                 printf("open failed\r\n");

                 printf("error=%d",ret);

 

               }        

            ret=f_read(ret,&f_data,4,1);            //read

            if(ret==FR_OK)

            {

                printf("WRITE SUCCESS\r\n");

            }

            else

                printf("WRITE failed\r\n");

 

thanks and regards,

sudhakar p

Outcomes