FIR low-pass Filter with fixed coefficients:(Change the coefficients in program to suite your needs):

Assembly Code:

ASM Code:
;ADC 0808 Interfacing with Atmel 89C51 uC ;wait till conversion is done   adc_a bit p2.0 ;define ADC pins connected to the pins of Microcontroller adc_b bit p2.1 adc_c bit p2.2   adc_sc bit p2.3 adc_ale bit p2.4 adc_oe bit p2.5 adc_eoc bit p2.6   ;filter coefficients K0 EQU 40 K1 EQU 62 K2 EQU 70 K3 EQU 62 K4 EQU 40   ;define input and o/p ports MYDATA EQU P1 OUT_D EQU P0   .org 0000h ;set start address to 0000h sjmp main ;jump to main program     main:     ;initialize these registers for storing partial products MOV R0, #00H MOV R1, #00H MOV R2, #00H MOV R3, #00H MOV R4, #00H   ;temporary storage for MSB and LSB of Partial Products MOV R6, #00H MOV R7, #00H         get_adc_data:   ;define my_data as i/p port MOV MYDATA, #0FFH ; mov OUT_D,#00h ;set port 3 as o/p port ; mov p3,#00h ;;set port 0 as o/p port     setb adc_eoc clr adc_oe clr adc_ale clr adc_sc   clr adc_a clr adc_b clr adc_c   setb adc_ale setb adc_sc clr adc_ale clr adc_sc   wait: jnb adc_eoc, wait ;wait till conversion is complete   setb adc_oe ;enable the Output port of ADC nop mov A, p1 ;move converted data from ADC to Accumulator mov p3, a ;move the unfiltered signal to port 3 ;nop clr adc_oe setb adc_eoc   filter:   MOV R0, A MOV B, #K0 MUL AB MOV R7, A MOV R6, B   MOV A, R1 MOV B, #K1 MUL AB ADD A, R7 MOV R7, A MOV A, B ADDC A, R6 MOV R6, A   MOV A, R2 MOV B, #K2 MUL AB ADD A, R7 MOV R7, A MOV A, B ADDC A, R6 MOV R6, A   MOV A, R3 MOV B, #K3 MUL AB ADD A, R7 MOV R7, A MOV A, B ADDC A, R6 MOV R6, A   MOV A, R4 MOV B, #K4 MUL AB ADD A, R7 MOV A, B ADDC A, R6   MOV OUT_D, A ;nop   Shift_adc_datas: MOV A, R3 MOV R4, A MOV A, R2 MOV R3, A MOV A, R1 MOV R2, A MOV A, R0 MOV R1, A       ajmp get_adc_data   END ;end of main program    

Download the code and Model here.