Both, 2.0.5 and 2.0.8 cores work with the “ONLY_RIGHT” option without change!!!
WRONG!
My statement on the previous post is WRONG!
I CHECKED AND RECHECKED, both with a simple “read-mic-plotter-serial” and the Edge Impulse Studio generated code… and, the statement above is NOT CORRECT!
My preliminary hallucination was a result of a DIRTY setup, running multiple IDEs at the same time, installing cores 2.0.5, 2.0.8, back-and-forth, and trying to test stuff…
DOING THE RIGHT WAY!
This time I did 3 copies of the Arduino binary, into 3 different directories, and in each one just one core version is installed (running in PORTABLE MODE).
Also, for testing purpose, only a single version of the IDE/core runs/test at a time, after the test shutdown the IDE and run another IDE/core to run tests…
Choose 3 ESP32 Arduino Cores: 2.0.5, 2.0.8 and 2.0.10 (latest).
Run everything TWICE, and the correct result follows below:
ONLY_RIGHT PORT 0 PORT 1
2.0.5 OK OK
2.0.8 X X
2.0.10 X X
ONLY_LEFT PORT 0 PORT 1
2.0.5 X X
2.0.8 OK OK
2.0.10 OK OK
So, changing the I2S Port, DOES NOT AFFECT RESULT!
This portion of the test was done with the following code:
(Open Serial Plotter to “see” the signal)
FOR PORT 0
#include <driver/i2s.h>
#define BUFFER_SIZE 512
#define I2S_MIC_SERIAL_CLOCK GPIO_NUM_26 //I2S_SCK
#define I2S_MIC_LEFT_RIGHT_CLOCK GPIO_NUM_32 //I2S_WS
#define I2S_MIC_SERIAL_DATA GPIO_NUM_33 //I2S_SDO
i2s_config_t i2s_config = {
.mode = (i2s_mode_t)(I2S_MODE_MASTER | I2S_MODE_RX),
.sample_rate = 16000U,
.bits_per_sample = I2S_BITS_PER_SAMPLE_16BIT,
.channel_format = I2S_CHANNEL_FMT_ONLY_RIGHT,
.communication_format = I2S_COMM_FORMAT_I2S,
.intr_alloc_flags = ESP_INTR_FLAG_LEVEL1,
.dma_buf_count = 8,
.dma_buf_len = 512,
.use_apll = false,
.tx_desc_auto_clear = false,
.fixed_mclk = 0
};
i2s_pin_config_t i2s_mic_pins = {
.bck_io_num = I2S_MIC_SERIAL_CLOCK,
.ws_io_num = I2S_MIC_LEFT_RIGHT_CLOCK,
.data_out_num = I2S_PIN_NO_CHANGE,
.data_in_num = I2S_MIC_SERIAL_DATA
};
void setup() {
Serial.begin(115200);
// start I2S PORT 0
i2s_driver_install(I2S_NUM_0, &i2s_config, 0, NULL);
i2s_set_pin(I2S_NUM_0, &i2s_mic_pins);
}
int16_t sample_buffer[BUFFER_SIZE];
void loop() {
// read I2S
size_t bytes_read = 0;
i2s_read(I2S_NUM_0, sample_buffer, sizeof(int16_t) * BUFFER_SIZE, &bytes_read, portMAX_DELAY);
int samples_read = bytes_read / sizeof(int16_t);
for (int i = 0; i < samples_read; i++)
{
Serial.printf("%ld\n", sample_buffer[i]);
}
}
.
.
FOR PORT 1
#include <driver/i2s.h>
#define BUFFER_SIZE 512
#define I2S_MIC_SERIAL_CLOCK GPIO_NUM_26 //I2S_SCK
#define I2S_MIC_LEFT_RIGHT_CLOCK GPIO_NUM_32 //I2S_WS
#define I2S_MIC_SERIAL_DATA GPIO_NUM_33 //I2S_SDO
i2s_config_t i2s_config = {
.mode = (i2s_mode_t)(I2S_MODE_MASTER | I2S_MODE_RX),
.sample_rate = 16000U,
.bits_per_sample = I2S_BITS_PER_SAMPLE_16BIT,
.channel_format = I2S_CHANNEL_FMT_ONLY_RIGHT,
.communication_format = I2S_COMM_FORMAT_I2S,
.intr_alloc_flags = ESP_INTR_FLAG_LEVEL1,
.dma_buf_count = 8,
.dma_buf_len = 512,
.use_apll = false,
.tx_desc_auto_clear = false,
.fixed_mclk = 0
};
i2s_pin_config_t i2s_mic_pins = {
.bck_io_num = I2S_MIC_SERIAL_CLOCK,
.ws_io_num = I2S_MIC_LEFT_RIGHT_CLOCK,
.data_out_num = I2S_PIN_NO_CHANGE,
.data_in_num = I2S_MIC_SERIAL_DATA
};
void setup() {
Serial.begin(115200);
// start I2S PORT 1
i2s_driver_install(I2S_NUM_1, &i2s_config, 0, NULL);
i2s_set_pin(I2S_NUM_1, &i2s_mic_pins);
}
int16_t sample_buffer[BUFFER_SIZE];
void loop() {
// read I2S
size_t bytes_read = 0;
i2s_read(I2S_NUM_1, sample_buffer, sizeof(int16_t) * BUFFER_SIZE, &bytes_read, portMAX_DELAY);
int samples_read = bytes_read / sizeof(int16_t);
for (int i = 0; i < samples_read; i++)
{
Serial.printf("%ld\n", sample_buffer[i]);
}
}
.
.
RUNNING ON EDGE IMPULSE STUDIO GENERATED CODE
When testing using the Edge Impulse Studio generated code, the same result as above come out… so, there is NO difference is results using EI Studio code or the simple app listed above!
Tests was done on:
Ubuntu 22.04 64BIT x86
Arduino IDE 1.8.19
ESP32 Cores 2.0.5, 2.0.8, 2.0.10
I will continue to look at the issue, this time onward looking at Espressif repo and searching for similar problems, in the hope to find some clarification about this behavior…
Hope it help somehow,
regards all,
Valter