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.
Advise on A/D converter sampling at 40khz
-
- Posts: 1708
- Joined: Mon Oct 17, 2022 7:38 pm
- Location: Europe, Germany
Re: Advise on A/D converter sampling at 40khz
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.)
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.)
Re: Advise on A/D converter sampling at 40khz
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.
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.
Re: Advise on A/D converter sampling at 40khz
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 87 guests