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
  • Here I observed one more thing. If I set the flag in main function as below:

    if(SD_flag==false) { SD_flag = true; } if(SD_flag==true) { SD_flag = false; SD_Write(); nrf_delay_ms(20); }

    I am able to write large data to SD card with less restarting and that to after storing 300kB in SD card. Why it is happening?

    Is it related to SPI clock frequency? I have kept it as 250 kHz. What should be the SPI0 clock frequency for SD card writing?

Reply
  • Here I observed one more thing. If I set the flag in main function as below:

    if(SD_flag==false) { SD_flag = true; } if(SD_flag==true) { SD_flag = false; SD_Write(); nrf_delay_ms(20); }

    I am able to write large data to SD card with less restarting and that to after storing 300kB in SD card. Why it is happening?

    Is it related to SPI clock frequency? I have kept it as 250 kHz. What should be the SPI0 clock frequency for SD card writing?

Children
No Data
Related