2018-08-13 03:45 AM
Hello, it is the first time when i have to deal with microphones and PDM interface. I just can't get correct data from the microphone, or the data is correct but i am doing something terribly wrong. I configure I2S to sample microphone with DMA. When DMA Rx callback is received, i do the processing of PDM data and send it to PC via USB VCP interface. Problem is that when i get the data in PC, there are some high frequency harmonics which are giving very anoying "beep" sound, even though in the background i can hear the "clap sound" that i am making with my hands. Could someone look at my code and tell me what am i doing wrong?
I attache the main file of my program, also the file where DMA controller of I2S is configured. I also attach pictures of how my signals look in frequency and time domains. Appreciate for the help if anyone could tell my what i am doing wrong.
By the way, i have read ST documents UM2372, AN5027. I do not see from them that i am doing something wrong.
I also add the recorded wav file. Listen it carefully and at low sound because the "beep" is really annoying. You can hear in the background that i am clap two times slowly, then one time i do a double clap quickly.
Will wait for the responses, cheers.
2018-08-30 08:45 PM
Hi, now it seems I can successfully sample audio data, below is the spectrum of 10KHz tone signal.
However, in an acoustically quiet room, the mic can still sample high freq noise, which confused me.
Now there are 2 things also confuse me:
I found that decimation factor should equals to # of PDM bits/# of PCM samples
2018-09-03 02:21 AM
J Lee, i still cant figure this one out. This just seems that it is not working the way it should work.
2018-09-03 02:49 AM
The best i can get is the photo attached. But still there is such a big noise in the signal, that when i listen it, i can barely hear the sound that i am doing by snapping my fingers near the microphone, even though i can see it in the time domain, but that is the best i can get, which still feels terrible...
2018-09-03 06:39 AM
I have noticed an interested thing. The I2S clock output frequency to the microphone is 1.024 MHz. My buffer to which i am getting data via DMA is declared as: uint16_t pdm_buff[32]. So my PDM buffer can accept 32*16 = 512 bits. Question: why do i keep getting I2S transfer complete interrupt every 1ms? It does not make sense to me. I attach my DMA configuration
hdma_spi2_rx.Instance = DMA1_Stream3;
hdma_spi2_rx.Init.Channel = DMA_CHANNEL_0;
hdma_spi2_rx.Init.Direction = DMA_PERIPH_TO_MEMORY;
hdma_spi2_rx.Init.PeriphInc = DMA_PINC_DISABLE;
hdma_spi2_rx.Init.MemInc = DMA_MINC_ENABLE;
hdma_spi2_rx.Init.PeriphDataAlignment = DMA_PDATAALIGN_HALFWORD;
hdma_spi2_rx.Init.MemDataAlignment = DMA_MDATAALIGN_HALFWORD;
hdma_spi2_rx.Init.Mode = DMA_CIRCULAR;
hdma_spi2_rx.Init.Priority = DMA_PRIORITY_VERY_HIGH;
hdma_spi2_rx.Init.FIFOMode = DMA_FIFOMODE_DISABLE;
2019-05-10 05:25 AM
Hi ArturasV!
Did you ever manage to get this to work correctly?
I've also been struggling with capturing 1 microphone at an i2s clock frequency of 1024 MHz. I get an audio signal but it's very noisy, particularly in the higher frequency range. I'm not sure if the problem lies with the sampling, or the PDM Filter. I don't really have the right tools for easily debugging this at hand. Any hints would be appreciated.
Thank you, Eos
2019-05-10 05:25 AM
Hi ArturasV!
Did you ever manage to get this to work correctly?
I've also been struggling with capturing 1 microphone at an i2s clock frequency of 1024 MHz. I get an audio signal but it's very noisy, particularly in the higher frequency range. I'm not sure if the problem lies with the sampling, or the PDM Filter. I don't really have the right tools for easily debugging this at hand. Any hints would be appreciated.
Thank you, Eos
2019-05-13 02:18 PM
2019-05-27 12:16 PM
Hi Eos. Pelzer, no - i gave up on this, we switched to another microphone. Did not manage to get this one working properly.