I'm using the following code to initialize and read from the i2s interface:
- i2s_config_t cfg = {
- .mode = I2S_MODE_SLAVE | I2S_MODE_RX,
- .sample_rate = 2048*1000 / 16, // BCK is 2048kHz, 16 bits per sample
- .bits_per_sample = I2S_BITS_PER_SAMPLE_16BIT,
- .channel_format = I2S_CHANNEL_FMT_ONLY_LEFT,
- .communication_format = I2S_COMM_FORMAT_STAND_PCM_SHORT,
- .intr_alloc_flags = 0,
- .dma_buf_count = 8,
- .dma_buf_len = 512,
- .use_apll = false,
- .tx_desc_auto_clear = false,
- };
- i2s_pin_config_t pin_cfg = {
- .bck_io_num = I2S_BICK_IO_CELL,
- .ws_io_num = I2S_LRCK_IO_CELL,
- .data_out_num = -1,
- .data_in_num = I2S_STDI_IO_CELL,
- };
- esp_err_t err = i2s_driver_install(1, &cfg, 0, NULL);
- if (err != ESP_OK) {
- DEBUG_PRINTF("Failure to install i2s driver for cell modem, %s\n",
- esp_err_to_name(err));
- }
- err = i2s_set_pin(1, &pin_cfg);
- if (err != ESP_OK) {
- DEBUG_PRINTF("Failure to configure i2s GPIO for cell modem, %s\n",
- esp_err_to_name(err));
- }
- while(1) {
- size_t bytes_read;
- err = i2s_read(I2S_NUM_CELL, data, sizeof(data), &bytes_read, 100 / portTICK_PERIOD_MS);
- if (err != ESP_OK) {
- DEBUG_PRINTF("Failure to read i2s data, %s\n", esp_err_to_name(err));
- }
- printf("read %d bytes\n", bytes_read);
- }
I've attached a logic analyzer to the I2S pins and captured the i2s data (screenshots attached), it seems like the data is all correct, except that the data frames come pretty far apart (there are about 200 sample periods between each frame signal). This seems like valid PCM, but I'm not sure if it could be introducing any problems.
If anyone can see something I'm doing wrong, or has any ideas of what to try, please let me know. Thank you!