I2S PDM mode - support for stereo microphones?

don_iguano
Posts: 4
Joined: Wed Apr 04, 2018 12:32 pm

I2S PDM mode - support for stereo microphones?

Postby don_iguano » Wed Apr 04, 2018 3:34 pm

Hi Guys, I've had success connecting this SPH0641LU4H-1 MEMS PDM microphone to I2S interface and it works - sound quality is great.

However, the incoming samples do not seem fall into their respective L/R channel - they appear the same regardless whether the mic is configured as L or R.

The data should be sampled on rising and falling edge of clock, and treated as two separate PDM streams. It rather looks as if the data was only sampled once and decimated into one channel.

Is stereo currently supported / will it be? My config looks like this:

Code: Select all

i2s_config_t i2s_config = {
	.mode = I2S_MODE_MASTER | I2S_MODE_RX | I2S_MODE_PDM,
	.sample_rate = 48000,
	.bits_per_sample = 16,
	.channel_format = I2S_CHANNEL_FMT_RIGHT_LEFT,
	.communication_format = I2S_COMM_FORMAT_PCM,
	.dma_buf_count = 2,
	.dma_buf_len = 8,
	.use_apll = 0,
	.intr_alloc_flags = ESP_INTR_FLAG_LEVEL1
};
pin_config = {
	.ws_io_num = 4, //PDM clock
	.data_in_num = 2, //PDM data
};
i2s_driver_install(I2S_NUM_0, &i2s_config, 0, NULL);
i2s_set_pin(I2S_NUM_0, &pin_config);
The clock generated at WS pin is at 3.072 MHz which looks good.

In i2s.h there are also constants PDM_SAMPLE_RATE_RATIO_64 and PDM_SAMPLE_RATE_RATIO_128 that might be relevant but are not used anywhere else in the framework.

p-rimes
Posts: 89
Joined: Thu Jun 08, 2017 6:20 pm

Re: I2S PDM mode - support for stereo microphones?

Postby p-rimes » Wed May 02, 2018 2:46 pm

@don_iguano, Were you able to configure two mics (L/R) on the same PDM-decoding-I2S interface?

don_iguano
Posts: 4
Joined: Wed Apr 04, 2018 12:32 pm

Re: I2S PDM mode - support for stereo microphones?

Postby don_iguano » Mon May 14, 2018 1:50 pm

@p-rimes not yet, was distracted by other project but will be looking at this problem again soon - and update here.

User avatar
fly135
Posts: 606
Joined: Wed Jan 03, 2018 8:33 pm
Location: Orlando, FL

Re: I2S PDM mode - support for stereo microphones?

Postby fly135 » Mon May 14, 2018 7:39 pm

Are you trying to get stereo from a single mic? I'm confused by your post, which seems to suggest that you only have one mic and want a stereo stream.

John A

User avatar
fly135
Posts: 606
Joined: Wed Jan 03, 2018 8:33 pm
Location: Orlando, FL

Re: I2S PDM mode - support for stereo microphones?

Postby fly135 » Mon May 14, 2018 8:31 pm

p-rimes wrote:@don_iguano, Were you able to configure two mics (L/R) on the same PDM-decoding-I2S interface?
I had no problems capturing stereo with two SPM1423HM4H mics.

John A

p-rimes
Posts: 89
Joined: Thu Jun 08, 2017 6:20 pm

Re: I2S PDM mode - support for stereo microphones?

Postby p-rimes » Thu May 24, 2018 7:13 pm

@fly135

Your setup (2 PDM mics multiplexed on a single I2S device (I2S0), with 1 channel for each mic) is exactly what I am hoping for.

Just to confirm, you were able to obtain independent data for 2 mics on I2S0 (one with the LR pin set high, the other set low, sharing the same GPIO pin).

Did you need any specific settings to accomplish this? (probably `I2S_CHANNEL_STEREO`, and `I2S_CHANNEL_FMT_RIGHT_LEFT`, `PDM_SAMPLE_RATE_RATIO_64`, `PDM_PCM_CONV_ENABLE`, and I'm not sure but maybe using `I2S_COMM_FORMAT_I2S | I2S_COMM_FORMAT_I2S_MSB`)?

don_iguano
Posts: 4
Joined: Wed Apr 04, 2018 12:32 pm

Re: I2S PDM mode - support for stereo microphones?

Postby don_iguano » Mon Mar 04, 2019 10:37 am

@fly135 @p-rimes thank you guys for your input. finally got chance to revisit this problem on a new board, hearing distinct sound from left and right mic although the signal is quite distorted - and with some combinations of settings (sampling rate, APLL) there is very loud ringing. will need to verify clocks with oscilloscope and try different mics, for example SPM1423HM4H
fly135 wrote:
Mon May 14, 2018 7:39 pm
Are you trying to get stereo from a single mic? I'm confused by your post, which seems to suggest that you only have one mic and want a stereo stream.

John A
yes initially I was trying to use one mic only and expected to hear sound in respective channel depending on mic L/R config but for some reason that did not have any effect, maybe there need to be two mics on the bus for this to work or there was a wiring problem.

Digvijay Reddy
Posts: 2
Joined: Thu Feb 09, 2023 3:53 am

Re: I2S PDM mode - support for stereo microphones?

Postby Digvijay Reddy » Wed Feb 22, 2023 5:35 am

@ don_iguano can u send the full code for the integration of 2 mics for stereo setup?

Who is online

Users browsing this forum: No registered users and 124 guests