cancel
Showing results for 
Search instead for 
Did you mean: 

Problems with filtered data of MEMS microphone MP34DT01 ussing library "pdm2pcm"

DPavl.11
Associate II

Good afternoon, I ran into such a problem. I use an MP32DT01 digital microphone and an STM32F411CE microcontroller. The data comes over I2S and is filtered by the "pdm2pcm" library from CUBE MX. But the sound has very strong noises, it is difficult to distinguish the voice. The filter parameters are shown in the 1st figure, the waveform of the received sound is shown in the 2nd figure. Can you please tell me what to do? How to get high-quality sound using this particular library for filtering and decimation? There is no way to use the "pdm_filter" library.

0693W0000059ZLbQAM.jpg0693W0000059ZLHQA2.png

9 REPLIES 9
Eleon BORLINI
ST Employee

Hi @DPavl.1​ ,

you could try to change the PDM_FILTER_DEV_FACTOR parameter from PDM_FILTER_DEV_FACTOR_64 to PDM_FILTER_DEV_FACTOR_80, to check if you get the same strange noise.

This because the MP34DT01 datasheet reports the low PDM clock frequency at 1MHz and if you are running at 1.024MHz you may be border line to this limit.

0693W0000059hwpQAA.png 

-Eleon

I tried to change the parameters, the noise did not disappear. I found out that the library does not provide a low pass filter. Could this be a problem and where to get (if any) examples of using such filters in use with a 16-bit PCM signal

Hi @DPavl.1​ ,

if you generate a pure tone( for example at 1kHz), are you then able to see it in the Audacity waveform?

If not, and if you are perceiving only high noise, can you check with a microscope or a lens watching through the microphone sound inlet on the top side of its package if the membrane of the MEMS microphone is OK? Or you can send me a picture of it and I'll tell you.

-Eleon

There is always noise. Everything is fine with the microon, I tested it using someone else's project with this microphone, where everything worked fine. But another library was used there for filtering and decimation and there was no such strong noise, everything was within normal limits. Therefore, the microphone is definitely all right.

Hi @DPavl.1​ ,

back to you after an internal double-check with an expert on this function.

A couple of things about the conversion:

  1. The PDMlib parameter for the I2S seem wrong;
  2. Probabily there is something wrong in the acquisition too (maybe related to the clock settings or to the buffers' management), or in the USB streaming of the data;
  3. You should note that basically the library acts just as a low-pass filter.

Our suggestion is the following:

  • Start from MEMSMIC1 library, the !microphone streaming for F401" example
  • The driver is already ready for the porting on F411, you have just to:
    • change the target from F401 to F411
    • change the define in the project options, from STM32F401xE to STM32F411xE)
    • change the files specific for the used microcontroller (startup and system file)
  • Check that the clock tree is correct with respect to the used hardware. The settings are referred to the use of the Nucleo board, so if you for example change the external quartz you have to modify the code accordingly.
    • Measure the microphone clock (maybe with an oscilloscope) for double-checking.

-Eleon

this is what I got using the "pdm_filter.h" library with a decimation factor of 80 and 16 kHz in the output. Can you tell me what to do? I tried to take an example from MEMSMIC1 and adjust it for my project, nothing came of it, a similar picture is obtained, I think the problem is either with the microphone itself or with the PDM stream, which I accept, because using the same library for filtering and decimation i get the same problems.

0693W000005Ah3cQAC.png

Hi @DPavl.1​ ,

you can share your application code, if you want.

You can check everything is consistent by measuring the microphone clock frequency before the filter application: if it is not 1.280MHz, maybe the MEMSMIC1 porting worked bad.

In that case, the suggestion is to check again the clock tree, according to the previoulsy mentioned "define".

-Eleon

DPavl.11
Associate II

For this case, the I2S initialization code:0693W000005ArxGQAS.jpgRCC initialization code:

0693W000005ArxVQAS.jpgPDM buffer processing:

0693W000005ArxpQAC.jpgpdm_filter initialization:

0693W000005ArxzQAC.jpg

Hi @DPavl.1​ ,

Please note that this code looks not coming from the MEMSMIC1 library, since it is using an old conversion library (different from the one you were using in your first screenshot). Now the API are different.

It is not clear what's happening in the conversion procedure... it looks like you are calling the library a number of "J" times,shifting every time of “DEC_FACTOR�? bytes. But if DEC_FACTOR is the decimation factor, this is wrong, since there is a factor of 8 missing (Bytes vs bits of the decimation factor).

There are also a number of collateral parameter that should be controlled: the DMA size (that library has to be called on 1ms time-base) the I2S register setting, etc...

Basically, it doesn't seem you are starting from the MEMSMIC1 library, or from an ST-supported code...

But maybe I'm not the right person for this, so I've added the STM32F4 tag to your post. You may ask for more support directly in the STM32 community.

-Eleon