2021-09-27 09:53 PM
Hi,
I am using ADC of STM32H743ZI which is configured as 16 bit, ADC clock =36.5MHz,Tsampling=1.5cycles in continuous conversion mode . I am using DMA technique to collect the data using a buffer size of 4096 in circular mode.
The input is sine wave of peak to peak voltage =3.3V whose frequency varies from 1Hz to 20K Hz.
In debug mode when I observed data stored in buffer I am able reconstruct the signal back but accuracy is very less (sample to sample there is lot of voltage difference) for high frequencies.
Since Tsampling is 1.5cycles and Tconversion is 8.5Cycles and ADC clock is 36.5 MHz sampling speed would be 3.65Msamples/sec.
What might be the issue for this low accuracy whether DMA is not able to store this high sampling speed data or Tsamping is creating a problem. Can any one help me out solving this problem.
2021-09-27 11:57 PM
Use a timer with the desired sampling freq. like 48 kHz or more. Configure it such that its output trigger (TRGO) is its Update Event.
Use ADC Regular Conversion Mode and configure the Timer Output Event as External Trigger Conversion Source. Leave the DMA output as is.
Now, the ADC should be triggered precisely with the desired freq. and you should receive a clean signal in the buffer.
Consult the ref.man. for what timers and ADCs can be combined.
Haven't done it on H7 so there might be more to consider.
hth
KnarfB
2021-09-28 12:19 AM
The sampling time may be a reason of low accuracy of ADC.
based on the STM32H743ZI datasheet, the Rin (ADC input impedance) =max 50Kohm and Cadc (internal sampling and hold capacitor) = 4pF. so the RC time constant could be 200nS, and to reach 16bit resolution the sampling time could be about 11 time constant 2200ns >> current sampling time 1.5x(1/36.5MHz)= 42nS. so the sampling capacitor seem not be charged enough to reach 16bit resolution.
2021-09-28 12:29 AM
sorry I made a mistake that Rin is 170ohm instead of 50Kohm...
in this case the RC time is 0.17x4=0.68ns and 11 time constant is 7.8ns. the sampling time of 42ns is enough.
2021-09-28 02:09 AM
Why we have to consider 11 time constants.
2021-09-28 02:17 AM
to reach 16bits resolution, the output of RC filter (sampling circuit) should be charged and reach "1- 1/(2^16)" of input.
at same time, the RC filter output is Vin x( 1- exp (- time of RC constant)), by calculation 11 time is needed to reach 16bit resolution.
2021-09-28 02:31 AM
Instead of DMA can I use a buffer of that size and store the values into buffer when ever conversion complete trigger is raised?
2021-09-28 02:33 AM
Ok, Should I use DMA to store the values or can I create a array and store into that array when ever adc conversion complete trigger is raised.
2021-09-28 02:37 AM
I think DMA is preferred for continue ADC sampling.
2021-09-28 02:37 AM
11 time constants is 7.8ns why again 42 ns is required.