Looking for a little guidance....or a lot of guidance.....
I want to make an averaging filter for a 12bit ADC. The 12 bits are unsigned.
I was thinking of a 16 element array and a FIFO operating scheme, where as each ADC reading is loaded into the array, the code then adds up all the elements in teh array, and then divides by 16 to get an average.
Simple enough right?
Heres my headscratcher. If the ADC maxes out to 0xFFF and I fill teh array 16 times with 0xFFF, the result is a 17 bit number(or 5 nibbles). - 0x15FEA to be exact.
So, what data type do I use for storing the result of the addition? I checked here:
And teh unsigned integer seems to fit the hole, but for GCC, based on what I read here:
Should I be using uint32_t ?
I am guessing YES, but I would like a second...or third..etc opinion(s)