2021-06-01 08:41 AM
2021-06-02 12:08 AM
the DMA automatically interleaves the ADC values.
It will fill (as a circular buffer if configured that way ) the array you pass as an argument, no matter the length untill you stop it.
uint32_t ADCReadings[1024];
//DMA will take hadc1 readings(interleaving channels) and store them inside ADCReadings array, the circular buffer created has legth 1024
HAL_ADC_Start_DMA(&hadc1, (uint32_t*) ADCReadings, 1024);
DMA will fill ADCReadings as follows: (if 4 channels from adc are activated)
.............
1024.ADCReadings[1023]= value from 4rd channel
2021-06-01 09:05 AM
you mean this?
https://www.youtube.com/watch?v=0jKtgP4OYvU
follow that video with 4 ADC inputs and create your DMA destination memory array as long as you want.
That channel is Great for learning stm32
2021-06-01 09:14 AM
You cannot put each channel into a separate location via DMA. They will all be interleaved and you'll need to move them around in memory as you require.
Probably better to rework your code to not require separate buffers.
2021-06-01 09:17 AM
A single circular 4 x 1024 array would be ideal...
2021-06-01 09:21 AM
Oh, so all results in the same buffer? Look at DMA ADC examples in the cube repository of the chip you're using. Or Javier's link. HAL_ADC_Start_DMA does this exactly.
2021-06-01 09:26 AM
Yes. That method should work. I can index into the interleaved circular buffer as a 4 by 1024 array. The DMA will handle the wrap around...
2021-06-01 09:27 AM
Thanks this approach should work.
2021-06-01 10:56 AM
I should clarify a bit. I have code to scan through four ADC channels and the result is placed in a 4 element circular buffer. This works.
Now I need to take those four elements and place them in a 1024 element circular buffer that is DMA driven. Javiar's refered video does the first part but I am still looking for help regarding the second part. If there is a way to interleave the four channels in a 4096 element array I can index into it and pull the values as needed but i have not seen a method to use the DMA to write my four ADC channel values to a 1024 circular buffer.
Thanks for your help on this.
2021-06-01 12:37 PM
HAL_ADC_Start_DMA takes the length of your buffer as the last argument. Change it from 4 to whatever you want.
2021-06-01 12:49 PM
Ok. Perfect. Thanks.
This won't affect the ADC channel scan since that is an ADC parameter...