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);
}