HI
I do a test connetting 16bit 2ch I2S ADC BOARD. I ground the signal and analyze it with logic analyzer. It show the value near +/-5count.
I got a strange signal when I write a arduino code to test. If I left all pin bit (LRCK/DATA/BITCK), no error reported from i2s_read() fucntion. The value in the buffer is all 0. I thought it should be a error returned.
Here is my test code
[Codebox]#include <driver/i2s.h>
#define I2S_SAMPLE_RATE 96000
//#define OUTPUT_PIN 27
#define READ_DELAY 9000 //microseconds
uint16_t adc_reading;
void i2sInit()
{
i2s_config_t i2s_config = {
.mode = (i2s_mode_t)(I2S_MODE_MASTER | I2S_MODE_RX),
.sample_rate = I2S_SAMPLE_RATE, // The format of the signal using ADC_BUILT_IN
.bits_per_sample = I2S_BITS_PER_SAMPLE_16BIT, // is fixed at 12bit, stereo, MSB
.channel_format = I2S_CHANNEL_FMT_RIGHT_LEFT,
//.communication_format = I2S_COMM_FORMAT_I2S_LSB,
.communication_format = I2S_COMM_FORMAT_I2S_MSB,
.intr_alloc_flags = ESP_INTR_FLAG_LEVEL1,
.dma_buf_count = 2,
.dma_buf_len = 256,
.use_apll = false,//change to true @20210613
.tx_desc_auto_clear = false,
.fixed_mclk = 0//
};
static const i2s_pin_config_t pin_config = {
.bck_io_num = 26,// BCKL
.ws_io_num = 25,// LRCL
.data_out_num = -1,
.data_in_num = 33 /* DOUT*/
};
i2s_driver_install(I2S_NUM_0, &i2s_config, 0, NULL);
i2s_set_pin(I2S_NUM_0, &pin_config);
}
void reader(void *pvParameters) {
uint32_t read_counter = 0;
int16_t buffer[128] = {0};
size_t bytes_read;
i2sInit();
while (1) {
if (i2s_read(I2S_NUM_0, &buffer, sizeof(buffer), &bytes_read, portMAX_DELAY) == ESP_OK) {
//esp_err_ti2s_read(i2s_port_ti2s_num, void *dest, size_t size, size_t *bytes_read, TickType_t ticks_to_wait)
i2s_stop(I2S_NUM_0);
if (bytes_read == sizeof(buffer)) {
read_counter++;
for (int x = 0; x <= (sizeof(buffer) / 4)-1; x++) {
// Serial.printf("u16 %02x %02X\n",buffer[2*x],buffer[2*x+1]);
// Serial.printf("i16 %02x %02X\n",int16_t(buffer[2*x]),int16_t(buffer[2*x+1]));
//Serial.printf("%04x\n",buffer[2*x]);
Serial.printf("%d %d\n", buffer[2 * x],buffer[2 * x+1]);
}
//delay(100);
} else {
Serial.println("buffer empty");
}
i2s_start(I2S_NUM_0);
} else {
Serial.println("timeout");
}
}
}
void setup() {
Serial.begin(115200);
// Put a signal out on pin
//uint32_t freq = ledcSetup(0, I2S_SAMPLE_RATE, 10);
// Serial.printf("Output frequency: %d\n", freq);
//ledcAttachPin(OUTPUT_PIN, 0);
// Initialize the I2S peripheral
// Create a task that will read the data
xTaskCreatePinnedToCore(reader, "ADC_reader", 2048, NULL, 1, NULL, 1);
}
void loop() {
}[/Codebox]
ESP32 i2s question
Jump to
- English Forum
- Explore
- News
- General Discussion
- FAQ
- Documentation
- Documentation
- Sample Code
- Discussion Forum
- Hardware
- ESP-IDF
- ESP-BOX
- ESP-ADF
- ESP-MDF
- ESP-WHO
- ESP-SkaiNet
- ESP32 Arduino
- IDEs for ESP-IDF
- ESP-AT
- ESP IoT Solution
- ESP RainMaker
- Rust
- ESP8266
- Report Bugs
- Showcase
- Chinese Forum 中文社区
- 活动区
- 乐鑫活动专区
- 讨论区
- 全国大学生物联网设计竞赛乐鑫答疑专区
- ESP-IDF 中文讨论版
- 《ESP32-C3 物联网工程开发实战》书籍讨论版
- 中文文档讨论版
- ESP-AT 中文讨论版
- ESP-BOX 中文讨论版
- ESP IoT Solution 中文讨论版
- ESP-ADF 中文讨论版
- ESP Mesh 中文讨论版
- ESP Cloud 中文讨论版
- ESP-WHO 中文讨论版
- ESP-SkaiNet 中文讨论版
- ESP 生产支持讨论版
- 硬件问题讨论
- 项目展示
Who is online
Users browsing this forum: Bing [Bot], Google [Bot] and 45 guests
- All times are UTC
- Top
- Delete cookies
About Us
Espressif Systems is a fabless semiconductor company providing cutting-edge low power WiFi SoCs and wireless solutions for wireless communications and Internet of Things applications. ESP8266EX and ESP32 are some of our products.