2018-07-05 05:27 AM
Hello!
As this issue has been going on for months now and there is no app note update, I guess it's time to pull our hands
out of our pockets and try to do something.
I was using the previous version of the pdm lib, and it used to work. Now I will describe what I'm doing. If some of your
are doing some experiments, let's share results.
1. Initialization.
I have noticed that cube mx produces some code in a file called pdm2pcm (.c, .h). It looks like this:
void MX_PDM2PCM_Init(void) {
/* USER CODE BEGIN 2 */ /* USER CODE END 2 */ /** */ PDM1_filter_handler.bit_order = PDM_FILTER_BIT_ORDER_LSB; PDM1_filter_handler.endianness = PDM_FILTER_ENDIANNESS_BE; PDM1_filter_handler.high_pass_tap = 2104533974;//7D70A3D6 PDM1_filter_handler.in_ptr_channels = 2; PDM1_filter_handler.out_ptr_channels = 2; PDM_Filter_Init(&PDM1_filter_handler); PDM1_filter_config.decimation_factor = PDM_FILTER_DEC_FACTOR_64; PDM1_filter_config.output_samples_number = 16; PDM1_filter_config.mic_gain = 0; PDM_Filter_setConfig(&PDM1_filter_handler, &PDM1_filter_config); /* USER CODE BEGIN 3 */ /* USER CODE END 3 */}// By the way does anybody know how to format code on this forum? I have tried selecting my code
// above and use the <> button on top right because it says it's for code, no way...
Back to the main problem:
* I suppose the 2 first init are fine. LSB and little endian sound OK to me.
* Now does anyone have an idea of what can be the high_pass_tap parameter? It cannot be a number
of taps, it would take ages. I tried to convert it to hexa (on the right) to check if it has something special and I
can't figure out...
* Now in channels and out channels are both 2 which is fine in this case because I want to do stereo first.
Now can anybody see any other configuration? If I have 4 microphones, I want (of course!!!) 4 output channels.
If I set 4 channels in input and 2 at the output, how will the calculation be performed? Average 2 by 2? Other?
Now for the configuration
* The oversampling factor seems right. In the previous lib, I was using a fonction, the name of which contains a 64,
and I was told at that time that it was the oversampling factor.
* output_samples_number: set as 16 from CubeMX. I'm not sure of what I do, but I have set it to 48 in the hope I
will get 48 samples per channel and per millisecond. I hope it's right.
* mic_gain is 0, which doesn't sound right. In fact, with a gain of 0, it probably wouldn't sound at all. I have set it to 32.
2. Runtime.
At this point, I have some inputs, some outputs, I will check tomorrow or this week end what's going on. And what's
going in and out from these operations, with memory screenshots. At least it doesn't crash.
Any comment and information welcome.
Pascal
2018-08-09 09:00 PM
For commercial projects contact your local sales/support office and find an FAE covering audio/pdm