-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Description
Environment
- Development Kit: NodeMCU + PCM1502A I2S DAC
- IDF version (
git rev-parse --short HEAD
to get the commit id.): Release/v3.3 (GIT8266O-490) #917 (release/v3.3) as well as master
//483a5a475c7afdf3336c66fa279c70de4bb8b750 - Development Env: Eclipse
- Operating System: Ubuntu
- Power Supply: USB + external 5V
Problem Description
I have no output from on I2S. I'am using official example:
https://github.com/espressif/ESP8266_RTOS_SDK/tree/master/examples/peripherals/i2s
Using i2s_write( )
function is hanging until timeout occurs without writing data into DMA Queue
i2s_write(I2S_NUM, samples_data, ((bits + 8) / 16)*SAMPLE_PER_CYCLE * 4, &i2s_bytes_write, 100); |
Every time i2s_bytes_write
is 0
Expected Behavior
Triangle and sine 100Hz wave on I2S DAC output
Actual Behavior
When Debug message level is set to INFO, serial monitor output is as expected:
Test bits=24 free mem=78188, written data=2880
I (5655) i2s: DMA Malloc info, datalen=blocksize=480, dma_buf_count=6
Test bits=16 free mem=78188, written data=1440
I (10735) i2s: DMA Malloc info, datalen=blocksize=240, dma_buf_count=6
Test bits=24 free mem=78188, written data=2880
I (15835) i2s: DMA Malloc info, datalen=blocksize=480, dma_buf_count=6
Test bits=16 free mem=78188, written data=1440
I (20915) i2s: DMA Malloc info, datalen=blocksize=240, dma_buf_count=6
but only reason why in this example is running is break
on timeout in `xQueueReceive'
ESP8266_RTOS_SDK/components/esp8266/driver/i2s.c
Lines 748 to 771 in cbfad90
while (size > 0) { | |
if (p_i2s_obj[i2s_num]->tx->rw_pos == p_i2s_obj[i2s_num]->tx->buf_size || p_i2s_obj[i2s_num]->tx->curr_ptr == NULL) { | |
if (xQueueReceive(p_i2s_obj[i2s_num]->tx->queue, &p_i2s_obj[i2s_num]->tx->curr_ptr, ticks_to_wait) == pdFALSE) { | |
break; | |
} | |
p_i2s_obj[i2s_num]->tx->rw_pos = 0; | |
} | |
ESP_LOGD(I2S_TAG, "size: %d, rw_pos: %d, buf_size: %d, curr_ptr: %d", size, p_i2s_obj[i2s_num]->tx->rw_pos, p_i2s_obj[i2s_num]->tx->buf_size, (int)p_i2s_obj[i2s_num]->tx->curr_ptr); | |
data_ptr = (char *)p_i2s_obj[i2s_num]->tx->curr_ptr; | |
data_ptr += p_i2s_obj[i2s_num]->tx->rw_pos; | |
bytes_can_write = p_i2s_obj[i2s_num]->tx->buf_size - p_i2s_obj[i2s_num]->tx->rw_pos; | |
if (bytes_can_write > size) { | |
bytes_can_write = size; | |
} | |
memcpy(data_ptr, src_byte, bytes_can_write); | |
size -= bytes_can_write; | |
src_byte += bytes_can_write; | |
p_i2s_obj[i2s_num]->tx->rw_pos += bytes_can_write; | |
(*bytes_written) += bytes_can_write; | |
} |
If You pass portMAX_DELAY
as ticks_to_wait
function i2s_bytes_write
will hang forever
When DEBUG info is enabled there should be info about samples write
ESP_LOGD(I2S_TAG, "size: %d, rw_pos: %d, buf_size: %d, curr_ptr: %d", size, p_i2s_obj[i2s_num]->tx->rw_pos, p_i2s_obj[i2s_num]->tx->buf_size, (int)p_i2s_obj[i2s_num]->tx->curr_ptr); |
like :
D (20915) i2s: size: 256, rw_pos: 16 , buf_size: 256, curr_ptr: 256
but there is no output like that.
Steps to repropduce
- Compile and run i2s example: https://github.com/espressif/ESP8266_RTOS_SDK/tree/master/examples/peripherals/i2s
- Set log verbosity to DEBUG
- Run again 'monitor` with debug info: no DMA write