
VMX51C1020
_________________________________________________________________________________________________
www.ramtron.com
page 23 of 80
VMX51C1020 FIR Filter Example
The example below shows how to use the
MULT/ACCU unit of the VMX51C1020 to
perform FIR filter computing. In order to
minimize the example size, only the FIR
computing function and the coefficient table are
presented.
;----------------------------------------------------//
;** FIR Filter Computing Function //
;---------------------------------------------------//
FIRCOMPUTE: MOV R0,#NPOINTSBASEADRS
;INPUT ADC RAW DATA
;AT Xn LOCATIONS...
;Saving acquired data from calling function into RAM for computation
MOV
VARH,DATAH
MOV
VARL,DATAL
MOV
@R0,VARH
INC
R0
MOV
@R0,VARFL
;** Prepare to compute Yn...
;***Define Base ADRS of input values
MOV
R0,#NPOINTSBASEADRS
;***Define Base Address of coefficients
MOV
R1,#COEFBASEADRS
MOV
R7,#NPOINTS ;DEFINE COUNTER
;***Configure the MULT/ACCU unit as Follow:
MOV
MACCTRL,#00001000B
;BIT7 LOADPREV = 0
;BIT6 PREVMODE = 0
;
;BIT5 OVMODE = 0
;
;BIT4 OVRDVAL = 0
;
;BIT3:2 ADDSRC = 10
;BIT1:0 MULCMD = 00
;**Clear the MULT/ACCU registers content
MOV
;** COMPUTE Yn...
COMPUTEFIR: MOVMACB1,@R1 ;Put a given Coefficient into
INC
R1
MOV
MACB0,@R1
INC
R1
MOV
MACA1,@R0 ; Put a given Xn Input into
INC
R0
MOV
MACA0,@R0
;This last instruction load the MACPREV register for next Operation
INC
R0
DJNZ
R7,COMPUTEFIR ;Do the Computation for N taps
;*** Second part
;-------------------------------------------------------------------------------------------------------//
;** SHIFT PREVIOUS INPUT VALUES TO LET PLACE FOR NEXT ONE...
;-------------------------------------------------------------------------------------------------------//
SHIFTPAST:
MOV
R7,#(NPOINTS-1)*2
;***COMPUTE FIRST FETCH ADDRESS
MOV
R0,#(NPOINTSBASEADRS - 1 + 2*(NPOINTS-1))
;***COMPUTE FIRST DESTINATION ADDRESS
MOV
R1,#(NPOINTSBASEADRS + 1 + 2*(NPOINTS-1))
SHIFTLOOP: MOV
A,@R0
;Shift Given LSB input...
MOV
@R1,A
;To next location
DEC
R0
;Prepare pointer for moving LSB
DEC
R1
DJNZ
R7,SHIFTLOOP
;** PERFORM TRANSFORMATION OF Yn HERE AND PUT INTO BINH, BINL
;** IN THIS CASE THE COEFFICIENTS HAVE BEEN MULTIPLIED BY 65536
;** SO THE RESULT IS ON 32-BITS
;** DIVISING YN BY 65536 MEAN ONLY TAKING THE UPPER 16-BITS
;(MSB)
;(LSB)
No manual Previous result
Automatic Previous result save when
MULT/ACCUA0 is loaded
Overflow flag remains ON until overflow
condition exist
The value of MACRES is the calculation
result
MACPREV is the Addition Source
Mul Operation = MACAxMACB
MACCTRL2,#0A0H
;MULT/ACCUB
;Define # of datashift
;To perform (N-1)*2
MOV
MOV
LCALL
MOV
RET
DATAH,MACRES3
DATAL,MACRES2
SENDLTC1452
P3,#00
;----------------------------------------------------
;* FIR Filter Coefficients Table *
;----------------------------------------------------
;FSAMPLE 480HZ, N=16, LOW PASS 0.1HZ -78DB @ 60HZ
COEFTABLE: DW 023DH
DW 049DH
DW 086AH
DW 0D2DH
DW 1263H
DW 1752H
DW 1B30H
DW 1D51H
DW 1D51H
DW 1B30H
DW 1752H
DW 1263H
DW 0D2DH
DW 086AH
DW 049DH
DW 023DH
DW 0FFFFH ;END OF TABLE