I want to compute a floating average of third order. Just take a look at my code:
void IRQ_Handler()__irq __ram { static long long unsigned int ACC1,ACC2,ACC3,ACC3D; static long long unsigned int D1,D2,D3,D1D,D2D; static unsigned int int_counter; char text[10]; T0CLRI = 0; ADCCON = 0x6A3; // software conv., single-ended, conv. enabled while (!ADCSTA){} // wait for end of conversion ACC1 += (ADCDAT >> 16) * 100; ACC2 += ACC1; ACC3 += ACC2; if (!(int_counter++ & 0x7F)) { D1 = ACC3 - ACC3D; D2 = D1 - D1D; D3 = D2 - D2D; ACC3D = ACC3; D1D = D1; D2D = D2; sprintf(text,"%8.d",D3 >> 21); SDA5708_printf(text); } }
befor i used long long there were overflow. If increasing Filter lenght there will be overflows even while using long long. Is there a work around?