2024-05-14 08:36 PM
Using STM32U5A5 MCU and adding the ADF example (taken from en.stm32cubeu5-v1-4-0\STM32Cube_FW_U5_V1.4.0\Projects\STM32U575I-EV\Examples\MDF\ADF_AudioRecorder) seems to work.
I have changed to use the PLL3 and setup 3,072MHz as PDM MIC CLK (for 48KHz sample rate, with decimation 64). Also this works (I see the correct PDM CLK on pin and also the data in buffer ADF filtering done looks reasonable).
I have two major questions:
Is using ADF for PDM MICs always Mono? (stereo MIC not possible)
Is there a DC Offset expected?
Solved! Go to Solution.
2024-05-15 09:53 PM
I've found a way to get rid of the DC offset: enable the High Pass Filter on ADF:
AdfFilterConfig0.HighPassFilter.Activation = ENABLE; //DISABLE; this seems to remove the DC offset
Now it works fine, except:
STM source code says, that the gain can be in 3dB steps up to value 24:
int32_t Gain; /*!< Filter gain in step of around 3db (from -48db to 72dB).
This parameter must be a number between Min_Data = -16
and Max_Data = 24 */
But it works for me just up to value 8, with 9 and larger - nothing works anymore.
It was tricky to setup the correct timing (PLL) to get ADF (for PDM MIC input) with SAI2 (as SPDIF output) to stay in sync all the time (a different story, maybe I share in a separate thread).
So, PDM MIC via ADF on a STM32U5A5 works fine now.
And: it is much better as any software based PDM2PCM approach (e.g. using this SW filter on a Portenta H7).
I do not see the harmonics (artefacts), it sounds much better, just the volume level is lower (but I can correct in the SW, in the "digital domain", e.g. scaling before forwarding the PCM sample values).
Here, how it looks like with ADF as PDM MIC input and a 1KHz sine wave from smartphone (pretty good):
My project is here:
2024-05-14 10:00 PM
BTW: I have played with the gain for the ADF filter.
The comments in code say this:
/*!< Filter gain in step of around 3db (from -48db to 72dB). This parameter must be a number between Min_Data = -16 and Max_Data = 24 */
What happens is:
I "must" get rid of this DC Offset, otherwise the gain setting does not make any sense!
It would move the DC Offset into saturation and the signal is clipped/lost (and not really amplified).
How to avoid this DC Offset?
2024-05-15 09:53 PM
I've found a way to get rid of the DC offset: enable the High Pass Filter on ADF:
AdfFilterConfig0.HighPassFilter.Activation = ENABLE; //DISABLE; this seems to remove the DC offset
Now it works fine, except:
STM source code says, that the gain can be in 3dB steps up to value 24:
int32_t Gain; /*!< Filter gain in step of around 3db (from -48db to 72dB).
This parameter must be a number between Min_Data = -16
and Max_Data = 24 */
But it works for me just up to value 8, with 9 and larger - nothing works anymore.
It was tricky to setup the correct timing (PLL) to get ADF (for PDM MIC input) with SAI2 (as SPDIF output) to stay in sync all the time (a different story, maybe I share in a separate thread).
So, PDM MIC via ADF on a STM32U5A5 works fine now.
And: it is much better as any software based PDM2PCM approach (e.g. using this SW filter on a Portenta H7).
I do not see the harmonics (artefacts), it sounds much better, just the volume level is lower (but I can correct in the SW, in the "digital domain", e.g. scaling before forwarding the PCM sample values).
Here, how it looks like with ADF as PDM MIC input and a 1KHz sine wave from smartphone (pretty good):
My project is here: