Gaps in ADC voltage response when using DMA
Gaps in ADC voltage response when using DMA
Hi,
I'm trying to run multi-channel DMA based ADC and I'm getting some strange results. Since this config isn't supported by the APIs I've had to manipulate the registers directly so it's possible I've done something wrong, but it isn't immediately obvious how an ADC could be misconfigured to behave like this. In the following plots I have simply logged the raw values returned from the ADC and plotted each sample as a dot. It's clear that there are multiple voltage regions in which no samples are ever returned. The problem remains with different bit widths and attenuation settings (although I can only try the 6 and 11 dB settings without adding a resistor network on the input).
Has anyone run into this before or have any suggestions?
I'm trying to run multi-channel DMA based ADC and I'm getting some strange results. Since this config isn't supported by the APIs I've had to manipulate the registers directly so it's possible I've done something wrong, but it isn't immediately obvious how an ADC could be misconfigured to behave like this. In the following plots I have simply logged the raw values returned from the ADC and plotted each sample as a dot. It's clear that there are multiple voltage regions in which no samples are ever returned. The problem remains with different bit widths and attenuation settings (although I can only try the 6 and 11 dB settings without adding a resistor network on the input).
Has anyone run into this before or have any suggestions?
Last edited by jkingdon on Sun Sep 06, 2020 5:14 pm, edited 1 time in total.
Re: Gaps in ADC voltage response
As an update, I created a simplified test case that only reads one channel and doesn't use any of my dubious register hacking, and it still shows the same behaviour. I've tested on three different esp32 and all behave in the same way, so it's not a single bad chip, and with different sources for the analog input, including the signal generator on my oscilloscope. I confirmed that the problem isn't visible when using the synchronous (non-dma) APIs.
The attached chart is from the single channel test case.
The attached chart is from the single channel test case.
- Attachments
-
- adc-gaps-1ch-standalone.jpg (127.46 KiB) Viewed 11323 times
Re: Gaps in ADC voltage response when using DMA
I've been unable to solve the gaps in the ADC data despite a fair bit of effort. I have some more esp32 on order to see if the newer chip revisions behave differently.
In the mean time, I've implemented multi-channel ADC on an STM32F103 and the data looks good. The following is a similar setup to the esp32 tests, raw results from one of four channels that were being sampled plotted as individual dots.
In the mean time, I've implemented multi-channel ADC on an STM32F103 and the data looks good. The following is a similar setup to the esp32 tests, raw results from one of four channels that were being sampled plotted as individual dots.
Re: Gaps in ADC voltage response when using DMA
can you repeat your simplified test after pulling low the PIN you're reading from ?
I had strange results recently when I was just reading mains frequency , and now all is good after
inverting the signal (had to do that instead of pulling low the PIN)
I had strange results recently when I was just reading mains frequency , and now all is good after
inverting the signal (had to do that instead of pulling low the PIN)
Re: Gaps in ADC voltage response when using DMA
Hi, what would pulling the pin low involve? I assume you don't mean externally as then there wouldn't be any signal to read, so I guess we're talking about the internal pull down on the digital input?
Re: Gaps in ADC voltage response when using DMA
I actually meant externally , If you're trying to read from INPUT pins like GPIO34 .. AFAIK it doesn't have internal resistors
see this thread , I ended up using 2n222 to invert the signal and only that made it work accurately
In my case I also couldn't pull down the PIN externally so I inverted the signal
viewtopic.php?f=19&t=17188
see this thread , I ended up using 2n222 to invert the signal and only that made it work accurately
In my case I also couldn't pull down the PIN externally so I inverted the signal
viewtopic.php?f=19&t=17188
Re: Gaps in ADC voltage response when using DMA
Thanks, I'll have to read through the link later. I don't think I can put an external pull down on the adc pin without influencing the voltage I'm trying to read. However, when I was wondering about crosstalk from the digital pin it made me realise that the pins I chose to use are the ones attached to the deprecated LNA. It's probably worth me testing with a different set of pins and see if things are any different.
Re: Gaps in ADC voltage response when using DMA
Sadly it wasn't the LNA causing problems, I get the same thing if I use ADC channel 4. I made a small test case to demonstrate the problem using the DAC to output a sine wave as a test signal. It was written for platformIO with the arduino framework but is small enough that it should be easy to port.
Re: Gaps in ADC voltage response when using DMA
I'm getting the same thing you have , even when I pulled it low .. same result
Re: Gaps in ADC voltage response when using DMA
Hey @plusorc many thanks for trying it out! It's good to know it's not just me/the esp32s I have here.
It seems unlikely this is a real problem in the hardware, after all, the ADC works if we call it without using DMA/I2S, so now the thing is to figure out what I've done wrong
It seems unlikely this is a real problem in the hardware, after all, the ADC works if we call it without using DMA/I2S, so now the thing is to figure out what I've done wrong
Who is online
Users browsing this forum: No registered users and 68 guests