Maximum PDM Clock rate (ESP32-WROVER)

geoffr
Posts: 2
Joined: Thu Dec 07, 2023 3:50 pm

Maximum PDM Clock rate (ESP32-WROVER)

Postby geoffr » Thu Dec 07, 2023 6:00 pm

I am looking to get a PDM clock rate high enough for an ultrasonic PDM microphone to work correctly. So far I have only been able to get a 10Mhz PDM clock - can a higher clock rate be acheived?

The maximum clock I have seen seems to relate to this comment in section "12.3 The Clock of I2S Module":
When ESP32 I2S works in slave mode, the master must use I2Sn_CLK as the master clock and fi2s >= 8 *
fBCK.
This means that if you use the APLL the max is 7.8125MHz and if you use the PLL_F160 (not as accurate) you get 10 MHz

My code is setting the I2S to Master mode, but I am unable to get above 10 MHz. Is there a way to have a PDM microphone connected in "master mode" with a higher clock rate?

Code:

Code: Select all

	i2s_config_t i2s_config = {
		.mode = (i2s_mode_t)(I2S_MODE_MASTER | I2S_MODE_RX | I2S_MODE_PDM),
		.sample_rate = sampleRate, 
		.bits_per_sample = I2S_BITS_PER_SAMPLE_16BIT,									
		.channel_format = t_channel,
		.communication_format = i2s_comm_format_t(I2S_COMM_FORMAT_PCM | I2S_COMM_FORMAT_PCM_SHORT), //(I2S_COMM_FORMAT_I2S | I2S_COMM_FORMAT_PCM_SHORT),//
		.intr_alloc_flags = 0,		//ESP_INTR_FLAG_LEVEL1,	
		.dma_buf_count = 4,
		.dma_buf_len = 512,
		.use_apll = false,
		.tx_desc_auto_clear = false,
		.fixed_mclk = 0,
	};

geoffr
Posts: 2
Joined: Thu Dec 07, 2023 3:50 pm

Re: Maximum PDM Clock rate (ESP32-WROVER)

Postby geoffr » Wed Dec 13, 2023 2:40 pm

Anybody have any ideas?

tpbedford
Posts: 31
Joined: Mon Feb 14, 2022 4:16 am

Re: Maximum PDM Clock rate (ESP32-WROVER)

Postby tpbedford » Thu Dec 14, 2023 4:07 am

Try:

Code: Select all

i2s_config.mclk_multiple = 1024;
I've not used PDM mode but in PCM mode if I leave this as 0 it seems to default to 256, which for me trying to use .fixed_mclk=16384000 would cause my actual mclk to top out at 4096000Hz. But, specifying mclk_multiple=1024 allowed me to hit 16.384MHz as requested.

The .mclk_multiple type is an enum whose defined values are the actual multiplier (128, 256, 384, 512) but non-enum values seem to work just fine.

Who is online

Users browsing this forum: No registered users and 58 guests