I would like to continuously read two ADC channels once every 1ms accumulating 500 values of each channel and perform a calculation every 500ms. I usually at slower speeds just use the ADC interrupt but this looks like a good candidate for DMA or DMA with a timer. What is the best way to do this? Does anyone have a step by step code example?
I would like to set the DMA source as the ADC, but the trigger to start a single ADC read f two of its channels from the timer.
When 500 readings x 2 have finished I expect the DMA interrupt to which I would restart the process but switching between two sets of 500 x 2 ADC values.
How do I configure the DMA to do this?
I guess transferring a single ADC reading is a 32 bit value even though the ADC is only 12bits.
So I would need 500x2x4x2 = 8000 ram bytes.
Any help or suggestions would be appreciated.
Thank you but I have read the Keil examples but can not see a way to use DMA to be efficient when I need to sample two consecutive ADC channels. The transfer width is 32 bits for a single ADC reading and there is no way I can see to set it to 64 bit for two readings without using the increment source option. To use the increment source option would mean I would have to set the data transfer to 2 readings and get an interrupt reset the source pointer. This is more code and adds complexity and does not seem to have a real advantage over using the CPU to read the ADC reading and trigger another reading every 1ms.
Is there any other way?
Check out some of the old examples to see if it helps. There is a ADC DMA example: