\ 16 bit 1-pole lowpass filter. implements: \ \ x += a (u - x) \ \ where a < 2^(-8). more specificly a = .00AA (2 HEX digits) \ \ internally, the filter has 24 bit precision to prevent roundoff \ errors, and one byte containing an unsigned filter coeff. \ suppose the state X is in 8.16 fixed point. this gives the values: \ x(z) = x0 + x1 z^-1 + x2^z-2 \ u(z) = u0 + u1 z^-1 + u2^z-2 \ d(z) = d0 + d1 z^-1 = u(z) - x(z) \ a(z) = a0 z^-2 \ from this follows that the low byte of d(z)a(z) can be dropped (or \ could be used to round?) and the rest is straighforward. \ sign correction is for (d0 + z) + d1 z^(-1), which is z * a0^z-2 = \ a0 * z^-1 \ temp vars for all filters: use vars used by multiplier. macro : D0 X0 ; \ difference (u - x) : D1 X1 ; : lpf/int-common | state | \ perform unsigned8 * unsigned16 multiplication + accumulation D0 @ state 3 + mulwf drop PRODL rot<