how to write/read data from SD card in frdmk64

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

how to write/read data from SD card in frdmk64

2,904 Views
sudhakarp
Contributor V

hi,

i am using FRDMK64 and kds3.0 and KSDK1.3.0. i tried USB device mass storage SD example. its working fine.

in this project only i want to implement FATFs file system. i want to read some file from SD card and i want to transfer that data through UART. if USB not connected at that time i want to access SD card. so that time i want to read/write some data from SD card. is possible..? for that what i have to do..?

 

 

give some suggestion or some example code.

 

regards,

sudhakar p

Labels (1)
0 Kudos
7 Replies

2,000 Views
BlackNight
NXP Employee
NXP Employee

Hi Sudhakar,

maybe this one is helpful for you: Tutorial: Data Logger with the FRDM-K64F Board | MCU on Eclipse

Erich

0 Kudos

2,000 Views
sudhakarp
Contributor V

hi,

i added fat_fs library and i tried to initialize "sdcard_disk_initialize(SD)". but i am getting failed error.

give some idea..? why i cant able to initialize?

i am doing following way:

void APP_init(void)

{

while (!sdhc_detect())

    {        ;

    } /* SD Card inserted */

    if(!SD_Init()) return; /* Initialize SD_CARD and SPI Interface */

ds = disk_initialize(SD);

//here i added my code***********************************************************************/

  if(ds)

  {

  printf("\nFailed to initialize SD disk\r\n");          //here i am getting initialization failed why?

  for(;;){}

  }

fr = f_chdrive(SD);

  printf("\nMounting file system to SD Card volume...\r\n");

fr = f_mount(SD, &FatFs);

  if(fr)

  {

  printf("\nError mounting file system\r\n");

  for(;;){}

  }

/***********************************************************************/

}

regards,

sudhakar p

0 Kudos

2,000 Views
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi, Sudhakar,

What is the error message? when did you confront error, in compiling stage or in running stage?

BR

Xiangjun Rong

0 Kudos

2,000 Views
sudhakarp
Contributor V

hi,

finally i achieved. i can able to read/write data on SD card. i forget to enable

#define CD_USING_POLL_DAT31

thats y i got error while initialization (run state)[disk_initialize(SD);]

regards,

sudhakar p

0 Kudos

2,000 Views
sudhakarp
Contributor V

hi,

please guide me how to initialize and use f_open, f_write for sd-card read/write. i struggling more.i have to solve this problem.

if any example available?

regards,

sudhakar p

0 Kudos

2,000 Views
sudhakarp
Contributor V

hi,

i added SD card fatfs library into work space and then i tried following method but i got error.what i am doing is correct..?is anyway to work like that..? i want to create one file then i want to write some data.fat_add.png

FIL* fp;

if (f_open(&fp,"log.txt", FA_OPEN_ALWAYS|FA_WRITE)!=FR_OK)

     {

     USB_PRINTF("\nSD card open error!\n");

     }

0 Kudos

2,000 Views
sudhakarp
Contributor V

hi erich,

i saw that tutorial. i am not experienced with processor expert. i am thinking it will create more problem to me and also i need SD-card USB mass storage also.so i am plan to use MSD example so in this project can you give idea how to implement SD-card read/write API.

thanks and regards,

sudhakar p

0 Kudos