Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 6 of 6

Thread: SD.open taking long time

  1. #1
    Junior Member
    Join Date
    Jul 2019
    Posts
    13

    SD.open taking long time

    Hi,
    I am trying to make a continuous recording device using Teensy3.5/3.6 and SPH0645 I2S mems microphone from adafruit. As per suggestions i got from this forum, i referred micro sound recorder and bat-detector project and adapted to sdfs library instead of regular sd library for faster read and write operations. I am able to record good quality audio with this setup but i am facing a issue where after recording around 15-20K 10 sec wav files on SD card, i am getting some files with 11sec timegap. When i play that audio file in media player, it plays properly but difference in timestamp (comparison with file recorder before current file) will be 11sec for some file. To debug this i did sdcard profiling and i found out that sd.open takes around 1sec if there are around 15-20k files already present in SDcard. I have tried this with high speed sdcards and results are same for all. Can anyone guide me for a solution for this?

  2. #2
    Senior Member
    Join Date
    Jul 2014
    Posts
    2,296
    What is the FAT of your microSD?
    It seems that exFAT is opening a little bit faster than FAT32. (sdfs allows exFAT)
    Also use only newly formatted disks for data logging.
    Most of these delays are due to the need of finding new and empty clusters, and updating FAT or Bitmaps.

  3. #3
    Junior Member
    Join Date
    Jul 2019
    Posts
    13
    Yes,i format SD cards before using them. I have tried with both FAT32 and exfat, same issue with both. When i keep device recording for long duration's, i see these 11 sec time gaps (10sec wavfile) keep coming after 15-20k files recorded.

  4. #4
    Senior Member
    Join Date
    Jul 2014
    Posts
    2,296
    OK,
    what happens is, that every time you open a file, the FS must scan the whole directory to see if it already exists. After a while this will need a lot of time.
    I suggest to create for each hour a directory so you have at most 360 files per directory. This should speed up searching for files.
    If you make the files longer say 60 s then I would create a directory for every day.

  5. #5
    Junior Member
    Join Date
    Jul 2019
    Posts
    13
    I tried creating new directory every hour and also tried with creating directory every day, but it's still having time gaps.

  6. #6
    Junior Member
    Join Date
    Jul 2019
    Posts
    13
    Hi,
    Can anyone tell me if projects like microsoud recorder and batdetector have similar issue, while recording file continuously?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •