I2S driver for ESP32 is not working [IDFGH-5854]
-
- Posts: 15
- Joined: Thu Jul 12, 2018 11:09 am
Re: I2S driver for ESP32 is not working [IDFGH-5854]
No worries. Thank you.
For external ADC, I am using following EVM from TI.
https://www.ti.com/tool/PCM1808EVM
If you want other information please let me know.
For external ADC, I am using following EVM from TI.
https://www.ti.com/tool/PCM1808EVM
If you want other information please let me know.
Re: I2S driver for ESP32 is not working [IDFGH-5854]
Hi shailesh.korat,
I wrote a test example to reproduce the issue you mentioned.
Here is the result: The data at the top line is at 48kHz sample rate with 2kHz sine input, middle line is at 96kHz sample rate with 2kHz input, bottom line is at 96kHz with 5kHz input. As you can see, I failed to reproduce this issue, maybe I should try another ADC codec.
For the reference and trouble shooting, this is my test project based on the latest master branch (by the way, the master branch on Github has not updated for several days, it should be synchronized sooner or later)
I wrote a test example to reproduce the issue you mentioned.
Platform: ESP32-LyraT-mini_V1.2 with ESP32-WROVER-B
Codec: ES8311
Signal Input: Generate sine wave at 2KHz & 5kHz by a signal generator
Sample rate: 48kHz & 96kHz
Stored data format: raw data
Here is the result: The data at the top line is at 48kHz sample rate with 2kHz sine input, middle line is at 96kHz sample rate with 2kHz input, bottom line is at 96kHz with 5kHz input. As you can see, I failed to reproduce this issue, maybe I should try another ADC codec.
For the reference and trouble shooting, this is my test project based on the latest master branch (by the way, the master branch on Github has not updated for several days, it should be synchronized sooner or later)
-
- Posts: 15
- Joined: Thu Jul 12, 2018 11:09 am
Re: I2S driver for ESP32 is not working [IDFGH-5854]
Thank you very much E-KAYA for sending me this details.
Now, let me try with your code. Instead of SD card, I am using flash memory to store output data of I2S.
Just want to clarify one thing is I am working on following commit id from master branch of ESP-IDF.
220590d599e134d7a5e7f1e683cc4550349ffbf8
Find attachment for more details.
I hope we are both on the same page.
Thanks.
Now, let me try with your code. Instead of SD card, I am using flash memory to store output data of I2S.
Just want to clarify one thing is I am working on following commit id from master branch of ESP-IDF.
220590d599e134d7a5e7f1e683cc4550349ffbf8
Find attachment for more details.
I hope we are both on the same page.
Thanks.
- Attachments
-
- idf_commit_id.PNG (44.17 KiB) Viewed 11725 times
-
- Posts: 15
- Joined: Thu Jul 12, 2018 11:09 am
Re: I2S driver for ESP32 is not working [IDFGH-5854]
Dear E-KAYA,
I checked with your given code example. Gave the 5khz sine wave to external ADC, and start sample from ESP32 with 48000 freq.
I used ESP32 instead of ESP32-S3 board.
But still I am getting noise output data.
Please check attachment for your reference.
FYI, current setup ADC + ESP32 is working fine and and getting correct output in IDF v4.3.
Let us know what could be the next step to follow to make this work.
Thanks
I checked with your given code example. Gave the 5khz sine wave to external ADC, and start sample from ESP32 with 48000 freq.
I used ESP32 instead of ESP32-S3 board.
But still I am getting noise output data.
Please check attachment for your reference.
FYI, current setup ADC + ESP32 is working fine and and getting correct output in IDF v4.3.
Let us know what could be the next step to follow to make this work.
Thanks
- Attachments
-
- esp32_48k_data.png (140.17 KiB) Viewed 11443 times
Re: I2S driver for ESP32 is not working [IDFGH-5854]
Few days ago, a fix commit (a287f34f88e78759cf09d2d9018b49adb70ea6fd) for apll clock is updated to the github, you can have a try with both 'apll on' and 'apll off' condition on the latest master branch. If it still not working, I might need your register dump for debugging.
-
- Posts: 15
- Joined: Thu Jul 12, 2018 11:09 am
Re: I2S driver for ESP32 is not working [IDFGH-5854]
Dear L-KAYA,
Thanks for supporting on this issue.
Finally, Something got works for me. Looks bit confusable but I2S working well now.
Here is few questions:
Sampling Freq : 48000, DMA buf len = 64, DMA buf cont = 8 , Read data using I2S_read = 64 *8, ch = 2, Sample bit= 32bit ---> Not working
Sampling Freq : 48000, DMA buf len = 48, DMA buf cont = 8 , Read data using I2S_read = 48 *8, ch = 2, Sample bit= 32bit ---> Working
Sampling Freq : 48000, DMA buf len = 96, DMA buf cont = 8 , Read data using I2S_read = 96 *8, ch = 2, Sample bit= 32bit ---> Working
Sampling Freq : 96000, DMA buf len = 64, DMA buf cont = 8 , Read data using I2S_read = 64 *8, ch = 2, Sample bit= 32bit ---> Not Working
Sampling Freq : 96000, DMA buf len = 96, DMA buf cont = 8 , Read data using I2S_read = 96 *8, ch = 2, Sample bit= 32bit ---> Working
Sampling Freq : 64000, DMA buf len = 64, DMA buf cont = 8 , Read data using I2S_read = 64 *8, ch = 2, Sample bit= 32bit ---> Working
Sampling Freq : 64000, DMA buf len = 96, DMA buf cont = 8 , Read data using I2S_read = 96 *8, ch = 2, Sample bit= 32bit ---> Not Working
Sampling Freq : 32000, DMA buf len = 32, DMA buf cont = 8 , Read data using I2S_read = 32 *8, ch = 2, Sample bit= 32bit ---> Working
Sampling Freq : 32000, DMA buf len = 64, DMA buf cont = 8 , Read data using I2S_read = 64 *8, ch = 2, Sample bit= 32bit ---> Working
In conclusion, The Samples only not missing when I keep DMA buf len in multiple of sampling freq (1 ms period).
Is this right behavior I2S ?
Thanks for supporting on this issue.
Finally, Something got works for me. Looks bit confusable but I2S working well now.
Here is few questions:
Sampling Freq : 48000, DMA buf len = 64, DMA buf cont = 8 , Read data using I2S_read = 64 *8, ch = 2, Sample bit= 32bit ---> Not working
Sampling Freq : 48000, DMA buf len = 48, DMA buf cont = 8 , Read data using I2S_read = 48 *8, ch = 2, Sample bit= 32bit ---> Working
Sampling Freq : 48000, DMA buf len = 96, DMA buf cont = 8 , Read data using I2S_read = 96 *8, ch = 2, Sample bit= 32bit ---> Working
Sampling Freq : 96000, DMA buf len = 64, DMA buf cont = 8 , Read data using I2S_read = 64 *8, ch = 2, Sample bit= 32bit ---> Not Working
Sampling Freq : 96000, DMA buf len = 96, DMA buf cont = 8 , Read data using I2S_read = 96 *8, ch = 2, Sample bit= 32bit ---> Working
Sampling Freq : 64000, DMA buf len = 64, DMA buf cont = 8 , Read data using I2S_read = 64 *8, ch = 2, Sample bit= 32bit ---> Working
Sampling Freq : 64000, DMA buf len = 96, DMA buf cont = 8 , Read data using I2S_read = 96 *8, ch = 2, Sample bit= 32bit ---> Not Working
Sampling Freq : 32000, DMA buf len = 32, DMA buf cont = 8 , Read data using I2S_read = 32 *8, ch = 2, Sample bit= 32bit ---> Working
Sampling Freq : 32000, DMA buf len = 64, DMA buf cont = 8 , Read data using I2S_read = 64 *8, ch = 2, Sample bit= 32bit ---> Working
In conclusion, The Samples only not missing when I keep DMA buf len in multiple of sampling freq (1 ms period).
Is this right behavior I2S ?
Re: I2S driver for ESP32 is not working [IDFGH-5854]
@shailesh.korat
Sorry for the late reply~
Thank you very much for your significant information! After some experiments, I think I find the reason of data clip (in other word, data lost).
Actually, received data buffer length is not really related to the dma_buf_len, but is related to the sample rate. When the sample rate is high (like 48k/96kHz), the receive interrupt will be more frequently. When the receive data buffer length is small, that means the DMA receive speed will be faster than data processing (in i2s_read), so the message queue in I2S is always full, the interrupt handler have to drop the old data in order to input the new data. Therefore, we need to set a bigger receive buffer. In this case, 'i2s_read' will spend more time on receiving data from DMA instead of processing the data, which can avoid DMA exhaust the message queue.
From my experience, when the sample rate is 48k, the receive buffer length should be greater than 1200, and in 96k, it should be greater than 3200.
Hope these information can help~
Sorry for the late reply~
Thank you very much for your significant information! After some experiments, I think I find the reason of data clip (in other word, data lost).
Actually, received data buffer length is not really related to the dma_buf_len, but is related to the sample rate. When the sample rate is high (like 48k/96kHz), the receive interrupt will be more frequently. When the receive data buffer length is small, that means the DMA receive speed will be faster than data processing (in i2s_read), so the message queue in I2S is always full, the interrupt handler have to drop the old data in order to input the new data. Therefore, we need to set a bigger receive buffer. In this case, 'i2s_read' will spend more time on receiving data from DMA instead of processing the data, which can avoid DMA exhaust the message queue.
From my experience, when the sample rate is 48k, the receive buffer length should be greater than 1200, and in 96k, it should be greater than 3200.
Hope these information can help~
-
- Posts: 15
- Joined: Thu Jul 12, 2018 11:09 am
Re: I2S driver for ESP32 is not working [IDFGH-5854]
Dear L-KAYA,
Nice to meet you again.
I am having different problem with I2S now.
By giving fix frequency(5k, 10k,15k etc.) sine wave from signal generator, ESP32S3 able to capture data correctly. I can see sine wave in audacity with fix frequency clearly.
Now instead of giving fix frequency as input, I an giving sweep sine wave from 500 Hz to 15 KHz as input with time period of 1 Sec,
If I do same test by just changing fix freq to sweep freq, Data sample is started to miss.
Find attached data file for your reference. You can clearly see missing data sample.
FYI, I have captured the sweep data by probing I2S using the logic analyzer and there is no any missing sample I have seen.
Looking forward to hearing from you soon.
Thanks.
Nice to meet you again.
I am having different problem with I2S now.
By giving fix frequency(5k, 10k,15k etc.) sine wave from signal generator, ESP32S3 able to capture data correctly. I can see sine wave in audacity with fix frequency clearly.
Now instead of giving fix frequency as input, I an giving sweep sine wave from 500 Hz to 15 KHz as input with time period of 1 Sec,
If I do same test by just changing fix freq to sweep freq, Data sample is started to miss.
Find attached data file for your reference. You can clearly see missing data sample.
FYI, I have captured the sweep data by probing I2S using the logic analyzer and there is no any missing sample I have seen.
Looking forward to hearing from you soon.
Thanks.
- Attachments
-
- sweep_sine_500Hz_to_5Khz_1.png (85.16 KiB) Viewed 10718 times
-
- sweep_sine_500Hz_to_5Khz.png (118.29 KiB) Viewed 10718 times
Re: I2S driver for ESP32 is not working [IDFGH-5854]
Dear shailesh.korat,
Nice to hear your feedback! Seems you met another data lost problem, I need some time to test this issue, but recently I wrote a specific example for the data drop issue, you can have a try and hope it can help.
The key is to create at least two receive buffers, if one is under processing, the others can still receive the data from isr. In this way, we can lower the time cost in the `i2s_read` loop and improve the efficiency.
By the way, may I ask did you change the i2s configurations during sampling? If you called `i2s_set_clk` the buffer might be cleared.
Thanks!
Nice to hear your feedback! Seems you met another data lost problem, I need some time to test this issue, but recently I wrote a specific example for the data drop issue, you can have a try and hope it can help.
The key is to create at least two receive buffers, if one is under processing, the others can still receive the data from isr. In this way, we can lower the time cost in the `i2s_read` loop and improve the efficiency.
By the way, may I ask did you change the i2s configurations during sampling? If you called `i2s_set_clk` the buffer might be cleared.
Thanks!
-
- Posts: 15
- Joined: Thu Jul 12, 2018 11:09 am
Re: I2S driver for ESP32 is not working [IDFGH-5854]
Dear L-KAYA,
Thank you for your reply.
I will try your example and let you know the result soon.
Just wanted to say that, In my application, receive buffer size from i2s_read is fixed 1536 bytes(192 samples * 8 bytes per sample = 1536 bytes) with sampling freq of 48000.
Could you explain me how did you count below overtim_tick period?
Thanks.
Thank you for your reply.
I will try your example and let you know the result soon.
Just wanted to say that, In my application, receive buffer size from i2s_read is fixed 1536 bytes(192 samples * 8 bytes per sample = 1536 bytes) with sampling freq of 48000.
Could you explain me how did you count below overtim_tick period?
Code: Select all
uint32_t overtime_tick = ((EXAMPLE_RECV_BUF_SIZE * 1000 * 8) / (EXAMPLE_SAMPLE_RATE * EXAMPLE_I2S_CHAN_NUM * EXAMPLE_SAMPLE_BIT)) / portTICK_RATE_MS;
Who is online
Users browsing this forum: No registered users and 93 guests