cancel
Showing results for 
Search instead for 
Did you mean: 

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?

SG.4
Associate II

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

6 REPLIES 6

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.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

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

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.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
SG.4
Associate II

ok Thanks the RTOS .. yes a newbie so, thanks by the way .

SG.4
Associate II

Hi @Community member​ ,

Could you please provide where are your worked examples link.

It would be of great help.

thanks

You'll need to look to generic examples of acquiring/releasing a mutex in your RTOS and apply those.

Alternatively perhaps look a queues, where a worker thread is responsible for all media interaction, and process them one after another.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..