cancel
Showing results for 
Search instead for 
Did you mean: 

STM32H7 DFSDM – Best way to read two microphones with one filter?

MannyMarc35
Associate II

Hi everyone,

I'm working on an audio acquisition project using the STM32H743ZIT6 microcontroller. The goal is to build a microphone array with 8 digital MEMS microphones (MP34DT05-A), connected via DFSDM and streamed over USB to a PC using the USB Audio Class (UAC). At the moment, I'm starting small and testing with one or two microphones.

So far, I have successfully configured one DFSDM filter and one channel using regular conversion with DMA, and I'm receiving valid audio data.

Now I would like to add a second microphone, which is connected to a second DFSDM channel (with opposite clock edge). Both channels should ideally be handled by the same DFSDM filter.

I'm currently wondering:

  • What is the best approach to sample two channels using a single DFSDM filter?

  • Is it necessary or recommended to use injected conversion for the second channel in this case?

  • How would I properly configure DMA and interrupts if both regular and injected conversions are used?

  • Are there any known working examples for this kind of setup?

Any tips, experiences, or suggestions would be greatly appreciated!

Thanks in advance

8 REPLIES 8
Saket_Om
ST Employee

Hello @MannyMarc35 


@MannyMarc35 wrote:
  • What is the best approach to sample two channels using a single DFSDM filter?


The best approach is to use the injected conversion with scan conversion enabled. 

Saket_Om_0-1754056170686.png

 

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.
Saket_Om
MannyMarc35
Associate II

Hi @Saket_Om ,

thanks for your reply.

I understand that both channels can be configured by using regular and injected conversion and triggered sequentially using one trigger event. However, I have a few open questions before proceeding:

 

  • Which trigger is most suitable for injected conversions in this setup?
    I see options like TIM1_TRGO, but I'm unsure whether that's the best choice or if I should use software trigger (trigger from regular conversion)

  • Is DMA supported for injected scan conversions?
    If yes, does it automatically copy both values (one per channel) into the buffer? Or would I need to manage the transfers manually (e.g. by reading via HAL_DFSDM_FilterGetInjectedValue() in the callback)?

  • Do I need a separate DMA stream for injected conversions?
    Currently, regular conversion uses DMA1_Stream0. Can injected use the same stream, or must I set up an additional DMA handle?

  • What’s the best way to synchronize the trigger and buffer handling?
    For regular conversions, the DMA transfer completes when the buffer is full. With injected conversions triggered periodically (e.g. by a timer), how should I design the timing so I don’t miss data or cause overlaps?

Of course, some kind of example would be best, but I appreciate any help. Thanks in advance.

 

Hello @MannyMarc35 

For audio applications, it is recommended to use the regular mode, which is typically used for continuous conversions from a single channel.

Saket_Om_0-1754299880553.png

 

Please refer to the document below for more details:

STM32L4_System_DFSDM.pdf

In your application, you need to configure 8 channels and 8 filters and then synchronize all the filters with filter 0. This allows all conversions to start simultaneously.

To use DMA, you also need to configure 8 DMA streams, one for each filter.

Please refer to the example project: Projects/STM32H743I-EVAL/Examples/DFSDM/DFSDM_AudioRecord,
which demonstrates the use of 2 DFSDM channels, 2 filters, and 2 DMA streams. To add an additional DFSDM channel, you need to configure it in the same way as filter 1 in the example.

  

 

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.
Saket_Om

Hello @Saket_Om ,

So, is it not possible or recommended to use a filter for two channels (regular + injected conversion)?
My problem is that the STM32H743ZIT6 only offers four filters and eight channels. Therefore, I wanted to use a filter for two channels.

Hello @MannyMarc35 

For audio application, usage of regular channel is recommended to guaranty the audio quality with continuous conversions (usage of timer or external trigger to launch injected conversions at specific time is very not easy to implement and not recommended). 

You need also to synchronize all your channels to guaranty audio samples synchronized (regular conversions are recommended because injected conversions on one filter are performed one after the other so not synchronously). 

Unfortunately, with only 4 filters, we recommend performing an audio record with only 4 digital microphones. If you require more filters, consider using the STM32H7A3/7B3 or STM32H7B0 series, which feature DFSDM with 8 channels and 8 filters.

 Saket_Om_0-1754312863124.png

 

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.
Saket_Om

Hi @Saket_Om ,

thanks for your support so far. But I still have one question.

When you say that I need to "synchronize all channels to guarantee audio samples are synchronized", what exactly does that mean in practice?

Is it enough if I simply configure the other 3 channels and filters the same way I did with just one?

I just want to make sure that all 4 microphones are perfectly synchronized from the first sample onward.

Thanks in advance!

Hello @MannyMarc35 


@MannyMarc35 wrote:

Hi @Saket_Om ,

When you say that I need to "synchronize all channels to guarantee audio samples are synchronized", what exactly does that mean in practice?


Please follow what is done in the example DFSDM_AudioRecord.
The filter 0 should be configured to be triggered by software.

  /* Initialize filter 0 (left channel) */
  __HAL_DFSDM_FILTER_RESET_HANDLE_STATE(&DfsdmLeftFilterHandle);
  DfsdmLeftFilterHandle.Instance                          = DFSDM1_Filter0;
  DfsdmLeftFilterHandle.Init.RegularParam.Trigger         = DFSDM_FILTER_SW_TRIGGER;

  And the filter 1 should be configured to be synchronized with filter 0

 /* Initialize filter 1 (right channel) */
  __HAL_DFSDM_FILTER_RESET_HANDLE_STATE(&DfsdmRightFilterHandle);
  DfsdmRightFilterHandle.Instance                          = DFSDM1_Filter1;
  DfsdmRightFilterHandle.Init.RegularParam.Trigger         = DFSDM_FILTER_SYNC_TRIGGER;
To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.
Saket_Om

Hello @MannyMarc35 

Anny update on this issue please? 

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.
Saket_Om