The i2s_write() call blocks when I try to pre-fill the TX DMA buffers.
I'd like to fill the DMA buffers before I call I2S_start() to minimize the possibility of underruns. However, i2s_write() doesn't return unless I2S is already started. Upon further testing and inspecting the i2s.c code, it seems, even if I2S is started, the i2s_write() api allows the filling of only one TX buffer at a time. After a single buffer is filled, a subsequent call will block from filling the next buffer until a i2s_reg->int_st.out_eof interrupt is received. Is my understanding correct? Is this the intended behavior? If so, what is the purpose of allocating multiple buffers?
Here is some sample code to illustrate the simplest case:
#define I2S_NUM (0)
void app_main()
{
size_t bytes_written;
i2s_config_t i2s_config = {
.mode = I2S_MODE_MASTER | I2S_MODE_TX,
.sample_rate = 16000,
.bits_per_sample = 16,
.channel_format = I2S_CHANNEL_FMT_ONLY_LEFT,
.communication_format = I2S_COMM_FORMAT_I2S | I2S_COMM_FORMAT_I2S_MSB,
.dma_buf_count = 8,
.dma_buf_len = 400,
.use_apll = true,
.intr_alloc_flags = ESP_INTR_FLAG_LEVEL1, // Interrupt level 1
.tx_desc_auto_clear = false,
};
i2s_pin_config_t pin_config = {
.bck_io_num = 19,
.ws_io_num = 23,
.data_out_num = 22,
.data_in_num = -1
};
i2s_driver_install(I2S_NUM, &i2s_config, 0, NULL);
i2s_set_pin(I2S_NUM, &pin_config);
i2s_stop(I2S_NUM);
ESP_LOGI(TAG, "begin write");
i2s_write(I2S_NUM, "X", 1, &bytes_written, portMAX_DELAY);
ESP_LOGI(TAG, "write complete"); /* never reaches here */
}
I2S_write blocks with unfilled DMA buffers
-
- Posts: 5
- Joined: Wed Dec 19, 2018 12:24 am
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: Baidu [Spider] and 96 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.