SPH0645 i2s microphone issue when migrate from legacy esp-idf version

kopyrmen
Posts: 3
Joined: Wed May 30, 2018 11:47 am

SPH0645 i2s microphone issue when migrate from legacy esp-idf version

Postby kopyrmen » Thu Jun 24, 2021 4:57 pm

Hello, I'm migrating code from esp-idf v3.2 to version v4.2.
I'm using SPH0645 i2s microphone to read sound data.
When I was migrate code to the new idf, values which comes from microphone are 0.
I run prevoius version of code which base on old idf and data are properly so it isn't hardware issue.
I2s init function and reading data are same in this two projects:

Code: Select all

#define LEN_WHOLE_BUFF			  4096
#define	LOW_FREQUENCY			  51
#define HIGH_FREQUENCY			  (( LEN_WHOLE_BUFF / 2 ) - 1 )

void i2sInit()
{
	i2s_config_t i2s_config = {
	   .mode = I2S_MODE_MASTER | I2S_MODE_RX,
	   .sample_rate = LEN_WHOLE_BUFF,
	   .bits_per_sample = I2S_BITS_PER_SAMPLE_32BIT,
	   .channel_format = I2S_CHANNEL_FMT_ONLY_LEFT,
	   .communication_format = (i2s_comm_format_t)(I2S_COMM_FORMAT_PCM | I2S_COMM_FORMAT_I2S_LSB ),
	   .dma_buf_count = 3,
	   .dma_buf_len =  512,
	   .use_apll = 1,
	   .intr_alloc_flags = ESP_INTR_FLAG_LEVEL3
	};
	i2s_pin_config_t pin_config =
	{
	   .ws_io_num =MIC_WS, //PDM clock
	   .data_in_num = MIC_DATA_IN, //PDM data
	   .bck_io_num = MIC_BCK,
	   .data_out_num = -1,
	};
	i2s_driver_install(I2S_NUM_0, &i2s_config, 0, NULL);
	i2s_set_pin(I2S_NUM_0, &pin_config);
}

//static void i2s_mesaurement( int * buff , int nos)
//{
//	size_t val = 0;
//	i2s_read(I2S_NUM_0 , buff, sizeof( int ) * nos, &val, portMAX_DELAY);
//}

void i2s_mesaurement( void * buff , int nos)
{
	size_t val = 0;
	i2s_read(I2S_NUM_0 , buff, 4 * nos, &val, portMAX_DELAY);
}
I saw one post which suggest that SPH0645 are incompatimble with timings in new idf. Could you confirm if it is issues with drivers in new idf? It is possibility to fix it ?

biterror
Posts: 31
Joined: Thu Apr 30, 2020 11:00 am

Re: SPH0645 i2s microphone issue when migrate from legacy esp-idf version

Postby biterror » Sat Jun 26, 2021 9:38 am

idf v4.2 broke my full-duplex i2s application as well, I had to change the data format to make it work again. They have changed some #defined values in the driver, maybe they have created a new bug somewhere..

kopyrmen
Posts: 3
Joined: Wed May 30, 2018 11:47 am

Re: SPH0645 i2s microphone issue when migrate from legacy esp-idf version

Postby kopyrmen » Sat Jun 26, 2021 10:27 am

Thank you for answer biterror.
Did you use before v4.1 and i2s communication was working ?
I have two option, change microphone or use older idf but lates version which I'm sure is working with SPH0645 is v3.2.

biterror
Posts: 31
Joined: Thu Apr 30, 2020 11:00 am

Re: SPH0645 i2s microphone issue when migrate from legacy esp-idf version

Postby biterror » Sun Jun 27, 2021 5:34 pm

I was using some development version (non-release) before, but with that version I had some problems in the Ethernet driver, so I had to upgrade.

Who is online

Users browsing this forum: noweare and 193 guests