Hi guys, I've found some oversampling code on below webpage:
http://focus.ti.com/general/docs/litabsmultiplefilelist.tsp?literatureNumber=slaa323
I'm trying to get 16 bit from a ADC12. I can't get a 16 bit result using below coding:
movingAVG -= AVGBuffer[AVGpnt];
movingAVG += ADC12MEM0;
AVGBuffer[AVGpnt++] = ADC12MEM0;
if (AVGpnt == 256)
AVGpnt = 0;
ADCresult = movingAVG >> 4;
But I can get the 16 bit result using below coding:
movingAVG += ADC12MEM0;
AVGpnt++;
if (AVGpnt == 256)
{
AVGpnt = 0;
ADCresult = movingAVG >> 4;
movingAVG = 0;
}
Aren't this two codes have the same function? Why is it the first one can't?