Advise on A/D converter sampling at 40khz

esp32S3
Posts: 3
Joined: Tue Aug 08, 2023 1:54 pm

Advise on A/D converter sampling at 40khz

Postby esp32S3 » Tue Aug 08, 2023 2:07 pm

Using an ESP32-S3 I need to sample a voltage at 40khz. I am using an ADS7822 A/D converter via SPI.
https://www.ti.com/product/ADS7822

I am seeking advise on how I could read this data into a DMA buffer behind the scenes without starving my 2 cores for CPU time.


Any ideas welcome.

MicroController
Posts: 1708
Joined: Mon Oct 17, 2022 7:38 pm
Location: Europe, Germany

Re: Advise on A/D converter sampling at 40khz

Postby MicroController » Wed Aug 09, 2023 9:46 am

The ADS7822 requires toggling the /CS to start each conversion. As per the TRM, sect. 30.5.8.5, the S3 can do "DMA-controlled" "segmented" transactions, where CS is toggled by hardware between segments.
However, there doesn't seem to be support for this feature in the IDF.

Another, "creative", option to explore could be to use two PWM outputs, one @ 40kHz for the CS signal and one @ >=(1+16)*40kHz for the DCLK; these two need to run synchronously. Then the ESP could act as an SPI slave to receive the data. (Not sure if, in slave mode, every rising /CS will still trigger one SPI interrupt anyway.)

esp32S3
Posts: 3
Joined: Tue Aug 08, 2023 1:54 pm

Re: Advise on A/D converter sampling at 40khz

Postby esp32S3 » Wed Aug 09, 2023 11:53 am

thanks for the ideas. I got it working (sort of) using I2S. I used the WS signal as my CS.
The only downside is WS goes low for left channel, and then high for the right. When I am done sampling I just chuck out every other word from the sample buffer.

esp32S3
Posts: 3
Joined: Tue Aug 08, 2023 1:54 pm

Re: Advise on A/D converter sampling at 40khz

Postby esp32S3 » Thu Aug 10, 2023 1:20 am

I was able to get the I2S working more like SPI, without having to skip every other word.

Who is online

Users browsing this forum: No registered users and 124 guests