This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

How to Write to SD Card at high rate ?

Hi All,

I have just started working on interfacing SD card with nrf52 using SDK 12.0. I have to write to SD card at a rate of 84 packets per second and each packet consists of 20 bytes. I am taking fatfs example in sdk 12.0 as reference.

I am sampling the SAADC at 1 ksps and storing these samples in SD card.Here I amwriting to SD card based on GPIO interrupt For each write operation I am using following steps: 1)open directory 2)open file 3)write bytes to file 4)close the file.

While writing continuously I am facing following issues :

  1. Code gets restarted automatically after writing some kb's into SD card.

  2. I am wring only in one file. Still additional files are generated in SD card.

  3. while writing to file somewhere in the middle I am getting massage as Unable to open or create file: ank.TXT.

I am using 8 GB SD card for this operation. IAR version 7.4 and SDK 12.0. Does any one has any idea why I am getting these issues?

I am attaching my code and some images for the reference. modified1.c image description image description image description

image1: when issue no. 3 occurred image2: when code gets restarted image3: when multiple files gets created in SD card

I have to write to SD card whole data at longer duration without restarting the code.

Parents
  • Can you print out the return code when you get the "unable to open or create file"? This should give you an indication of what is wrong. Something like this:

    NRF_LOG_INFO("Unable to open or create file: " FILE_NAME ".\r\n");
    NRF_LOG_INFO("Error code: %d\r\n", ff_result);
    

    You can also try to check the return code of the f_close function to check if the file was successfully closed.

Reply
  • Can you print out the return code when you get the "unable to open or create file"? This should give you an indication of what is wrong. Something like this:

    NRF_LOG_INFO("Unable to open or create file: " FILE_NAME ".\r\n");
    NRF_LOG_INFO("Error code: %d\r\n", ff_result);
    

    You can also try to check the return code of the f_close function to check if the file was successfully closed.

Children
No Data
Related