STM32H7 and PDM2PCM filter (for PDM microphones)
I have some questions and remarks about the PDMFilter (used for PDM MICs).
I have it working fine on a Portenta H7. Almost all OK.
I have studied the UM2372 : STM32Cube PDM2PCM software library for the STM32F4/F7/H7 Series - User manual
Here are my questions:
1. Source Code:
Is there any chance to get the source code (GitHub) for this (new version of) filter implementation?
2. Filter implementation details:
OK, the current version is now using an IIR filter (OK, I understand maybe why: code size, speed, latency). The older version (not recommended and supported anymore), was based on FIR, I could still find here:
codec2_m4f/lib/PDM_filter at master · piratfm/codec2_m4f · GitHub
a) the IIR filter:
generates some artefacts (in spectrum, even documented in UM2372, e.g. a remarkable 3rd harmonics). I think to see that also other "side tones" are generated (OK).
The PDM2PCM filter is very sensitive for the right amplification setting (and with which amplitude the signal from PDM comes in). Obvious.
If you do something not really "right", e.g. too much amplification (gain) or a too strong signal, what happens (and I can "see" and hear):
- the output signal starts clipping (it becomes a "rectangle")
- and suddenly the filter starts with "self-oscillation": I assume, it starts already to generate "side tones" when it reaches a too high amplitude on output (IIR feeds it back)
All this is acceptable (and obvious), just: "maybe a 'better' " filter design is possible.
b) Please, may I get more details about the filter implementation:
- Which order (how many taps) is this IIR filter? (what are the coefficients?)
- Is it implemented by using floating point math (or based on ARM DSP with fix point)?
- Is it using the HW FPU unit? (I do not think so, nothing mentioned to enable it)
- Is it using Dithering (to handle Quantization Errors and rounding errors)?
- Is there an AGC (I do not think so, but Windows via USB would add one - pay attention!)
Below some examples what I get (from a generated 1KHz PDM sine signal, fed into PDMFilter (not a real MIC signal, no MIC or a speaker involved, a "pure" PDM signal played from buffer - OK, it generates also "side tones").
So, even it works nice, I am thinking to implement my own PDMFilter (as FIR, with ARM DSP and Fix Point math, potentially using the HW FPU).
Or: does anybody has one already? (or if STM thinking to provide source code for one?)






