cancel
Showing results for 
Search instead for 
Did you mean: 

PDM2PCM and I2S Data Frame relation

frnt
Senior

Dear @Eleon BORLINI​ ,

I’m currently using the I2S peripheral to acquire from a digital microphone.

The I2S is configured as:

  • 24bits on 32bit data frame
  • 22kHz sampling frequency

and the pdm library is correctly configured and I’m able to convert a single sample (uint16 m) at a time and stream it. The pdm buffer is 16 (uint16) used as circular buffer by the dma.

My question is where is the relation between the 24bits in 32bit data frame and the pcm converted sample, which is always on 16bits (uint16). Am I loosing precision in this way?

I don’t see any difference in setting the i2s with 24/32 on 32bit data frame since I’m only obtaining 16bit pcm samples.

is there some configuration that I’m missing?

Could it be the pInternalMemory[…] variable in the pdm configuration struct?

thanks a lot

1 ACCEPTED SOLUTION

Accepted Solutions
Federica Bossi
ST Employee

Hi @frnt​ ,

PDMFilter is expecting a 24bit data. It makes the PDM to PCM conversion and to a bit shift so to obtain the 16 bit signal in output.

If the data in input is 16 bit, the above bit shifting will generate a messy and noisy signal.

I suggest you to let the I2S configured at 24bit.

If you need a specific I2S configuration that requires working at 16 bit, can you share with us?

In this way we can double-check the proper configuration for PDMFilter.

If my reply answered your question, please click on Select as Best at the bottom of this post. This will help other users with the same issue to find the answer faster

In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.

View solution in original post

9 REPLIES 9
Federica Bossi
ST Employee

Ciao @frnt​ ,

In general you are right, but it depends on the microphone you are using.

The greater part of ST products has a SNR that fits the 16 bit resolution.

There are few (final part number HP – High Performance) that can also works at 24 bit of resolution.

For those product a separate HP_PDM filter is available in X-CUBE-MEMSMIC1 package.

We have no product that has a dynamic range or a SNR that need 32 bit of resolution.

That’s why we should not experiencing any noticeable difference in setting 24/32 or 32: the exceeding bits are only noise.

In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.
frnt
Senior

Dear @Federica Bossi​ ,

thanks a lot for your reply and clarification. Therefore, if I understand correctly for non-HP products that have 16bits resolution, using i2s with 16bits on 16bit dataframe is fine? This off course will lower the output PDM clock by half.

I have tried putting 16bits on 32bits dataframe but the converted PCM is a mess and I do not understand why.

How the pdm2pcm relates this resolution (16/24 or 32) when processing the pdm stream into pcm?

Best,

Federica Bossi
ST Employee

Hi @frnt​ ,

PDMFilter is expecting a 24bit data. It makes the PDM to PCM conversion and to a bit shift so to obtain the 16 bit signal in output.

If the data in input is 16 bit, the above bit shifting will generate a messy and noisy signal.

I suggest you to let the I2S configured at 24bit.

If you need a specific I2S configuration that requires working at 16 bit, can you share with us?

In this way we can double-check the proper configuration for PDMFilter.

If my reply answered your question, please click on Select as Best at the bottom of this post. This will help other users with the same issue to find the answer faster

In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.

Hello @Federica Bossi ,

I have a final question. I’m using the i2s configured as 24bit on 32bit data frame as suggested. I don’t understand why the actual audio sampling frequency is half of the sampling frequency set in the i2s configuration. Eg. For 44kHz I get a final audio pcm that is sampled at 22kHz. For a 10s audio recording I should get a file with size: (44kHz*10*2)/1024 = 859kB, but the actual pcm file size is only 430kB.

Do you have suggestion for that? Am I doing something wrong?

 

Thanks

Piranha
Chief II

The PDM stream has no multi-bit samples with a "bit resolution" like PCM data, because it's a 1-bit continuous sigma-delta stream. Of course, as the hardware works with bytes, it packs that 1-bit stream into N-byte words, but that has nothing to do with audio signal itself.

I've not used these things, but for a PDM stream 24-bit data in 32-bit data frame seems suspicious, because after every 24 bits it looses the next 8 bits. Most likely one has to capture all bits of the data frame.

Hello @Piranha ,

yes, I’m already capturing the pdm stream into the correct frame, the calling the pdmFilter I get the pcm uint16.

My question is about the missmatch between the sampling frequency set in the i2s configuration (ioc) and the sampling frequency of the actual pcm audio file, which is half of the one set in the ioc. Could it be related to the decimation factor been wrong?

It could be the decimation factor. Also it could be wrong number of channels somewhere in the chain.

frnt
Senior

The channel is only 1, I have a single microphone connected in a mono configuration. The PDM library is configured with 1 channel and 128 decimation factor.

Piranha
Chief II

But I2S always has two channels. So think about what the "I2S frequency" is. Anyway, you know the rates, formats and data sizes you need - put in some test variables and debug where the error is.