Andries Tip wrote: > ;------------------------------------------------------------------------= ---- > ; 1:256 Finite Impuls Response Filter for 16-bit values - Andries Tip 201= 2 > ;------------------------------------------------------------------------= ---- [snip] > ;------------------------------------------------------------------------= ---- >=20 > FIR_256_16BIT ; average =3D (255*average + setpoint)/25= 6 >=20 > movf average0,w ; average =3D 256*average - average =3D 2= 55*average > sublw d'0' ; prepare carry > movwf temp ; save value for rounding later, otherwis= e we cannot reach 65535 > movf average1,w ; > subwfb average0,f ; > movf average2,w ; > subwfb average1,f ; > movlw d'0' ; > subwfb average2,f ; >=20 > movlw d'255' ; average =3D round((average + setpoint)/= 256) > addwf temp,w ; > movf setpoint1,w ; > addwfc average0,f ; > movf setpoint2,w ; > addwfc average1,f ; > clrw ; > addwfc average2,f ; >=20 > ;------------------------------------------------------------------------= ---- This is NOT an FIR filter; it's a straight single-pole recursive (IIR) filt= er. -- Dave Tweed --=20 http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist .