cancel
Showing results for 
Search instead for 
Did you mean: 

The best approach to write MEMS microphone values into an SD CARD

ALope.1
Associate II

Hello everyone,

I have been programming a MEMS microphone with a desirable rate of 48KHz. I'm working on a STM32L433 Nucleo Board and the data from microphone is being acquired via DMA with SAI protocol. I process the PDM data to PCM through PDM2PCM library.

Now I want write the output of the PDM2PCM function in a SD CARD. I'm using a SPI protocol but it seems insufficient for this high volume of data. This board hasn't a big value of RAM, so it is not possible to record a lot of data and save later. Even changing my code structure, I'm always falling in HardFaultException. I think it is only the SAI DMA Callback being called and naturally interrupting the data writing on the card (made with common FATSD functions). Am I right?

I think the better approach is using DMA for the SD card writing too. Maybe I need to change the protocol that I'm using for something faster as SDIO?

My final goal is making a data logger with Microphone Data for 24 hours of autonomy.

I hope anyone could give me some guidance on this problem.

Thank you!

1 REPLY 1
Eleon BORLINI
ST Employee

Hi @ALope.1​ , I can suggest you to check the STM32L4 example package of the STWIN kit, where there is an application example called HS_Datalog (folder \Projects\HS_DataLog). This is the example of a fast datalogger that saves all the audio stream / data on the onboard SDCARD (or on USB): the comments across the code are well documented. Regards