ADC with Circular DMA works almost as expected. It is off by a 16-bit word. Can it be fixed?
I am reading 4 values, AN0, AN1, Temp, and the Reference. (But reference may go away.)
I am over sampling 16x. and eventually will be starting a sequence every 100 us.
I wanted two buffers, so I could work on one, while filling the other.
I thought a circular buffer would work. I make it 8 16-bit words and have a half-full buffer interrupt go when the first 4 words are done, and have the buffer-full interrupt go when the second 4 words are finished.
It does work that way.
The only issue is that it starts on second memory location not the first.
When I prefill the array with zeros, the array looks like this after the first transfer.
<invalid data> <data 0> <data 1> <data 2> <data 3> 0 0 0
And after the second DMA transfer it looks like this
<data 7> <data 0> <data 1> <data 2> <data 3> <data 4> <data 5> <data 6>
And after the third DMA Transfer it looks like this:
<data 7> <data 8> <data 9> <data 10> <data 11> <data 4> <data 5> <data 6>
Is there a way to fix this so the first data transfer starts on the first memory location? Or what am I doing wrong?
This is a STM32G031
And I am using HAL_ADC_Start_DMA() to start the DMA.
Here is what the ADC registers look like after the first transfer.
ADC_ISR: 200A
ADC_IER: 0010
ADC_CR: 10000001
ADC_CFGR1: 00000003
ADC_CFGR2: 2000000D
ADC_SMPR: 00000336
ADC_AWD1TR: 0FFF0000
ADC_AWD2TR: 0FFF0000
ADC_AWD3TR: 0FFF0000
ADC_CHSELR: 00003003
ADC_DR: 00005DAF
ADC_AWD2CR: 00000000
ADC_AWD3CR: 00000000
ADC_CALFACT: 00000035
ADC_COMMON_CCR: 00C00000
I think I can make it work the way it is, but it would be easier if it were aligned right.
