How do I use the ADC mode for i2s is esp-idf v5.2.2?

clodman84
Posts: 3
Joined: Sat Jun 08, 2024 6:21 pm

How do I use the ADC mode for i2s is esp-idf v5.2.2?

Postby clodman84 » Sat Jun 08, 2024 6:27 pm

The docs mention that I2S0 can be routed directly to the internal analog-to-digital converter (ADC) and digital-to-analog converter (DAC). In other words, ADC and DAC peripherals can read or write continuously via I2S0 DMA. As they are not actual communication modes, the I2S driver does not implement them. The driver does not implement the LCD mode either.

I want to record audio using the ADC and i2s. This used to be possible in the earlier versions of the idf used to have a way to enable ADC mode and I have found examples that do this using an older version of the idf and it seems fairly straightforward here.

I am new to esp-idf, can someone show me how I would implement this, or steps that I can take to do this. Thanks

ESP_Sprite
Posts: 9668
Joined: Thu Nov 26, 2015 4:08 am

Re: How do I use the ADC mode for i2s is esp-idf v5.2.2?

Postby ESP_Sprite » Sun Jun 09, 2024 1:27 am

You can use this driver for that.

clodman84
Posts: 3
Joined: Sat Jun 08, 2024 6:21 pm

Re: How do I use the ADC mode for i2s is esp-idf v5.2.2?

Postby clodman84 » Sun Jun 09, 2024 4:51 am

I've looked into this but how would I configure the i2s drivers. Will i2s_read() start reading from this buffer? How do I make multiple buffers using the continuous mode driver. Some code would help. Thanks

ESP_Sprite
Posts: 9668
Joined: Thu Nov 26, 2015 4:08 am

Re: How do I use the ADC mode for i2s is esp-idf v5.2.2?

Postby ESP_Sprite » Sun Jun 09, 2024 7:03 am

You do not have to do anything with I2S if you use that driver; it handles the fact that on the ESP32 the data transfer happens to go through I2S entirely for you.

jtwaleson
Posts: 2
Joined: Sun Oct 20, 2024 2:26 pm

Re: How do I use the ADC mode for i2s is esp-idf v5.2.2?

Postby jtwaleson » Sun Oct 20, 2024 2:37 pm

ESP_Sprite wrote: You do not have to do anything with I2S if you use that driver; it handles the fact that on the ESP32 the data transfer happens to go through I2S entirely for you.
Hi @ESP_Sprite,

Nice to see a fellow Tweaker here ;) I have to say I'm really confused whether i2s dac is possible in esp-idf 5.x . The i2s_adc_enable from the 4.x api is now gone.

If I start i2s first and then enable the adc continuous example I get:

Code: Select all

i2s_platform: i2s controller 0 has been occupied by i2s_driver
The other way round I get:

Code: Select all

W (13156) i2s_platform: i2s controller 0 has been occupied by adc
E (13166) i2s_common: i2s0 might be occupied by other component
Any pointers would be very appreciated!

ESP_Sprite
Posts: 9668
Joined: Thu Nov 26, 2015 4:08 am

Re: How do I use the ADC mode for i2s is esp-idf v5.2.2?

Postby ESP_Sprite » Mon Oct 21, 2024 1:16 am

There's no need to start I2S in ESP-IDF V5. The continuous ADC driver should take care of setting up I2S by itself.

jtwaleson
Posts: 2
Joined: Sun Oct 20, 2024 2:26 pm

Re: How do I use the ADC mode for i2s is esp-idf v5.2.2?

Postby jtwaleson » Mon Oct 21, 2024 7:11 pm

Ok thanks for clarifying. But then how do I set up the pin numbers and sample rate configuration etc for i2s? Sorry if this is a stupid question.

Also, I was manually setting up i2s and continuous adc for testing purposes to get something working. My actual goal is to use the bluetooth classic hfp_hf example which sets up i2s under the hood. I'm getting the feeling I can't have the continuous adc and hfp_hf both trying to automagically set up i2s for me?

Who is online

Users browsing this forum: No registered users and 78 guests