MCS51單片機的濾波程序
;限幅濾波程序
;入口??? :A,SDAT,DELTY
;占用資源:B
;堆棧需求:2字節
;出口??? :A
JUGFILT? :MOV??? B,A
????????? CLR??? C
????????? SUBB?? A,SDAT
????????? JNC??? JUGFT1
????????? CPL??? A
????????? INC??? A
JUGFT1?? :SETB?? A
????????? SUBB?? A,#DELTY
????????? JNC??? JUGFT3
????????? MOV??? A,SDAT
????????? RET
JUGFT3?? :MOV??? A,B
????????? MOV??? SDAT,A???
????????? RET
;中位值濾波程序
;入口??? :ADDPH,ADDPL,N
;占用資源:ESELSORT
;堆棧需求:4字節
;出口??? :A
MEDFILT? :LCALL? ESELSORT
????????? MOV??? A,N
????????? CLR??? C
????????? RRC??? A
????????? ADD??? A,ADDPL
????????? MOV??? DPL,A
????????? MOV??? A,ADDPH
????????? MOV??? DPH,A
????????? JNC??? MEDFT1
????????? INC??? DPH
MEDFT1?? :MOVX?? A,@DPTR
????????? RET
;N點算術平均濾波
;入口??? :ADDPH,ADDPL,N
;占用資源:B,R3,R4
;堆棧需求:2字節
;出口??? :A
AVFILT?? :MOV??? A,ADDPL
????????? MOV??? DPL,A
????????? MOV??? A,ADDPH
????????? MOV??? DPH,A
????????? CLR??? A
????????? MOV??? R3,A
????????? MOV??? R4,A
????????? MOV??? R7,N
AVFT1??? :MOVX?? A,@DPTR
????????? INC??? DPTR
????????? ADD??? A,R4
????????? MOV??? R4,A
????????? JNC??? AVFT2
????????? INC??? R3
AVFT2??? :DJNZ?? R7,AVFT1
????????? MOV??? R7,N
????????? MOV??? R2,#00H
????????? LCALL? NDIV31
????????? MOV??? A,R4
????????? RET
;N點加權平均濾波
;入口??? :ADDPH,ADDPL,N
;占用資源:B,R3,R4
;堆棧需求:2字節
;出口??? :A
QAVFILT? :CLR??? A
????????? MOV??? R3,A
????????? MOV??? R4,A
????????? MOV??? R7,N
????????? MOV??? P2,ADDPH
????????? MOV??? R1,ADDPL
????????? MOV??? DPTR,#QAVTAB
QAVFT1?? :MOVC?? A,@A+DPTR
????????? MOV??? B,A
????????? MOVX?? A,@R1
????????? INC??? DPTR
????????? INC??? R1
????????? MUL??? AB
????????? ADD??? A,R4
????????? MOV??? R4,A
????????? MOV??? A,B
????????? ADDC?? A,R3
????????? MOV??? R3,A
????????? DJNZ?? R7,QAVFT1
????????? MOV??? A,R4
????????? JNB??? ACC.7,QAVFT2
????????? INC??? R3
QAVFT2?? :MOV??? A,R3
????????? RET
QAVTAB?? :DB
;一階加權滯后濾波程序
;入口??? :A,DELTY
;占用資源:B,R3,R4
;堆棧需求:2字節
;出口??? :A
BQFILT?? :MOV??? B,A
????????? CLR??? A
????????? MOV??? DPTR,#ABTAB
????????? MOVC?? A,@A+DPTR
????????? MUL??? AB
????????? MOV??? R4,A
????????? MOV??? R3,B
????????? MOV??? A,#01H
????????? MOVC?? A,@A+DPTR
????????? MOV??? B,DELTY
????????? MUL??? AB
????????? ADD??? A,R4
????????? MOV??? R4,A
????????? MOV??? A,B
????????? ADDC?? A,R3
????????? MOV??? R3,A
????????? MOV??? A,R4
????????? JNB??? ACC.7,FT1
????????? INC??? R3
FT1????? :MOV??? A,R3
????????? MOV??? DELTY,A
????????? RET
BQTAB??? :DB???? 80H,80H
評論
查看更多