atomic14/diy-alexa

ADC-related compile errors when shifting to ESP32S3

Opened this issue · 5 comments

hi Chris! Some of my students are doing Marvin projects again, and I realise the ADC has changed on the S3 :(
Have you seen this in any of your projects? I've been trying to fix compile errors like lib/audio_input/ADCSampler.cpp:16:5: error: 'i2s_adc_enable' was not declared in this scope but not having much luck and perhaps would need a more thorough understanding of the ADC peripheral library in IDF...
Best, Hamish

According to the docs the old API remains in the same place, with new API in new headers. I think the issue is that the S3 also doesn't support some of the old API so they've removed it. Apparently the S3 doesn't support I2S on ADC2, so functions calls i2s_set_adc_mode(m_adcUnit, m_adcChannel); aren't valid any more, at least in the old API.

If ADC is not used, just delete lib/audio_input/ADCSampler.cpp and lib/audio_input/ADCSampler.h and reference to the header in main. Comment out REG_SET_BIT(I2S_TIMING_REG(getI2SPort()), BIT(9)); REG_SET_BIT(I2S_CONF_REG(getI2SPort()), I2S_RX_MSB_SHIFT); then delete I2S_MODE_ADC_BUILT_IN in main. Now your code is messed for good, but works :) However my audio feedback is not right on S3, there is sound that resembles the sound file but is more of a noise. Still trying to figure out if is software or i did something silly with hardware or choosing of the pins.

If ADC is not used, just delete lib/audio_input/ADCSampler.cpp and lib/audio_input/ADCSampler.h and reference to the header in main. Comment out REG_SET_BIT(I2S_TIMING_REG(getI2SPort()), BIT(9)); REG_SET_BIT(I2S_CONF_REG(getI2SPort()), I2S_RX_MSB_SHIFT); then delete I2S_MODE_ADC_BUILT_IN in main. Now your code is messed for good, but works :) However my audio feedback is not right on S3, there is sound that resembles the sound file but is more of a noise. Still trying to figure out if is software or i did something silly with hardware or choosing of the pins.

Hey there @sanyi ! From the research I have been doing, it seems the ESP32 has a good amount of radio noise from the Bluetooth and Wifi that seems to make its way into the ADC, as is outlined in this video, around this timestamp: https://www.youtube.com/watch?v=pPh3_ciEmzs&t=241s

Are you using either of those features? If so, I'd try and turn them off and see what your results are like after that.

Also, it is possible that what you are getting is the exact behavior one should expect if they circumvent the disability to use I2S on the internal ADC, if I am to understand that that is what you are doing.