2018-10-07 04:37 AM
I'm sampling a single ADC with 3 channels using DMA.
Let's say the requested data size for each channel is 1024. So this is the code for starting DMA:
uint16_t buffer[1024*3];
HAL_ADC_Start_DMA(&hadc1, buffer, 1024*3);
Now when HAL_ADC_ConvCpltCallback() returns, I assume buffer is filled in the following way:
buffer[0]: channel 0
buffer[1]: channel 1
buffer[2]: channel 2
buffer[3]: channel 0
buffer[4]: channel 1
buffer[5]: channel 2
buffer[6]: channel 0
buffer[7]: channel 1
buffer[8]: channel 2
etc.
My question is: can I configure it to be automatically filled like the following:
buffer[0] = channel 1
buffer[1] = channel 1
buffer[2] = channel 1
buffer[3] = channel 1
...
buffer[1023] = channel 1
buffer[1024] = channel 2
buffer[1025] = channel 2
...
buffer[2047] = channel 2
buffer[2048] = channel 3
buffer[2049] = channel 3
...
buffer[3071] = channel 3
But still sampled in tandem (I just want the order to be consecutive for each channel).
Of course I can do it manually but my question is if there's a configuration to make it done automatically. I'm using CubeMX if that makes any difference...
2018-10-07 06:43 AM
>>My question is: can I configure it to be automatically filled like the following
No
2018-10-08 12:15 AM
And such a large buffer would be a real waste of RAM.