Skip to main content
Visitor II
August 7, 2021
Question

Hello ST Experts , I have a stm32f745 ,which creates a single file and writes a string array in SD card using FATFS, but now I want to create multiple files which appends the PDM2PCM middleware converted PCM buffer values. from the 3 MEMS acquired?

  • August 7, 2021
  • 1 reply
  • 2706 views

Certain things which are unclear are :

1) When I increase the size of the PDM buffer and PCM buffer say to 2000 ,4096 to collect more samples for storing to convert them into a larger file into.wav or mp3 , I find no creation of the file in SD card .The audio_process() function which invokes PDM2PCM conversion ,here at this point it loops into step running and hard fault.

What could be the possible reason I am unable to figure it?Could anyone please clarify what is exactly happening?

2) Creating the multiple files which appends the incoming values and keeps writing them ?What could be possibly be used?

Please some suggestions.

Thanks in advance

--

Shweta

    This topic has been closed for replies.

    1 reply

    Graduate II
    August 7, 2021

    Buffering size shouldn't inherently be a problem. SD cards will prefer binary multiples, and multiples of 512 bytes.

    Hard Fault suggests you're outside the bounds of the buffering, or have some stack issue. They catch gross failures, not simple/subtle logic ones.

    Use a HardFault_Handler() that outputs useful information and review the specific code that is faulting. I've posted multiple examples of this.

    Multiple files, also should not be a specific issue. There might be settings in ffconf.h

    What can be a problem is not having individual contexts for each file. ie a FIL structure

    The FatFs and SDIO/SDMMC layers below are NOT inherently thread safe. The peripheral and cards can only handle a single stream of consciousness, so use/ownership needs to be arbitrated if you don't have a single thread/loop managing the file writing/reading.

    I would completely avoid doing any file interaction under interrupt or callback context.

    SG.4Author
    Visitor II
    August 9, 2021

    Hi @Community member​ ,

    Thank you for your response ,where could be the stack issue resolved ,could you please suggest. ? Is it before generating the code where we give the file , in the Advance linker settings .

    >> The individual contexts means for a each file should we have define the FIL structure for every particular new file that we create.

    >>what in detailing is meant by the ownership/ needs arbitration?

    Thanks in advance .

    --

    Shweta

    Graduate II
    August 9, 2021

    It means you need a mutex or semaphore to grant ownership to the resource, so a single thread can own the resource whilst it uses it, and the ability of other tasks to wait, or retry later, if the resource is being used elsewhere.