cancel
Showing results for 
Search instead for 
Did you mean: 

Is it possible to store values of ADC every time it changes, I wanted to store them in DMA and do the average of samples? or Do i need to use an external sd card through i2c and store them in it?

Apill
Senior
 
1 ACCEPTED SOLUTION

Accepted Solutions

"Every time it changes" is a bit vague, every time the conversion completes it triggers a DMA transfer to a buffer, you can get an interrupt for the HT (Half) and TC (Complete) points in the buffer, which you want reasonably deep to reduce interrupt loading, and then you can do a running average of the inactive half of the buffer.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

View solution in original post

3 REPLIES 3

"Every time it changes" is a bit vague, every time the conversion completes it triggers a DMA transfer to a buffer, you can get an interrupt for the HT (Half) and TC (Complete) points in the buffer, which you want reasonably deep to reduce interrupt loading, and then you can do a running average of the inactive half of the buffer.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Apill
Senior

thanks for the response, which brings me to a hypothesis DMA can store the values of ADC after conversion.???? after storing i would like to do the average of all the numbers stored in them.

Ok, so you'd traverse the array in the interrupt, summing the values, and computing your average.

DMA in this context just auto-fills the array in the back ground, and you get an interrupt at various fill levels/points.

What the DMA can't do is wait for the value on the ADC to vary, or do the summing.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..