?? fir_bnch.a96
字號:
;******************************************************************
;* BENCHMARK: FIR 16-tap filter 80296SA (State Time = 40nS)
;* DATE: 09-012-1996
;* MODIFIED BY: Navin Govind
;* Intel Corporation
;******************************************************************
;Perform FIR calculations using the following equation
;For an impulse response of h(0), h(1).... h(N-1) and input x(n)
;at time 'n', the output y(n) at time n is given by:
;y(n) = h(0)*x(n) + h(1)*x(n-1)+....+h(N-1)*x[n-(N-1)]
; FIR FILTER USING MAC ("DEDICATED" FIR)
;This program illustrates the use of the MAC instruction in the implementation
;of an FIR digital filter.
;The coefficient here were simply chosen as a portion of a ramp, 16 taps from 0
;to 15. This was done not to illustrate a useful filter, but to make it easier
;to recognize the coefficients and trace them through the memory sections where
;they appear.
;The program is for the 296SA, and can be assembled with the Version 5
;cross-assembler from Tasking. After linking with LINKER, and conversion with
;OH196, the object file can be loaded and run on the 296SA eval board.
;Another example using index registers is as follows
; START:
; LDB ICB0,#01H ;SET UP INCREMENT CONTROL BYTE REG
; LDB ICB1,#01H
; LD IDX0,SAMPLE ;INIT SAMPLE POINTER
; LD IDX1,COEFF ;INIT COEFFICIENT POINTER
; SMACZ ICX0,ICX1 ;DO INITIAL MPY, ZERO ACC
; RPT #0EH ;REPEAT NEXT INSTR 15X
; SMACR ICX0,ICX1 ;DO 15 SUCCESSIVE MAC'S WITH INC
; MSAC YOUT,#018H ;PLACE RESULTS IN YOUT
; END
$include(_SFR_INC_)
YOUT equ 0
XIN equ 1
ERR equ 2
YLAST equ 3
RSEG AT 020h
;Working register declarations
temp: dsw 2
temp_l equ temp
temp_h equ temp+2
out: dsw 2
out_l equ out
out_h equ out+2
;Length of filter (N) = 15
loop: dsb 1
;Locations of x(n-(N-1))
coeff: dsw 2
coeff_0 equ coeff
coeff_1 equ coeff+2
coeff_2 equ coeff+4
coeff_3 equ coeff+6
coeff_4 equ coeff+8
coeff_5 equ coeff+10
coeff_6 equ coeff+12
coeff_7 equ coeff+14
coeff_8 equ coeff+16
coeff_9 equ coeff+18
coeff_10 equ coeff+20
coeff_11 equ coeff+22
coeff_12 equ coeff+24
coeff_13 equ coeff+26
coeff_14 equ coeff+28
;Locations of h(n-1)
sample: dsw 2
sample_0 equ sample
sample_1 equ sample+2
sample_2 equ sample+4
sample_3 equ sample+6
sample_4 equ sample+8
sample_5 equ sample+10
sample_6 equ sample+12
sample_7 equ sample+14
sample_8 equ sample+16
sample_9 equ sample+18
sample_10 equ sample+20
sample_11 equ sample+22
sample_12 equ sample+24
sample_13 equ sample+26
sample_14 equ sample+28
;
CSEG
;MCS(r) 96 family of microcontrollers reset after power-up at 2080h
CSEG AT 0FF2080H
ejmp START
;The following four 'clr' instructions may not be needed for 80926SA
;if the contents of temp and out regs are not read initially
START:
ld sp,#STACK ;set up stack depth
ldb wsr,#1Eh ;set 128 byte window
clr temp_l ;initialize temp register
clr temp_h
fir macro coef, samp, num
mul temp, coef&num, samp&num
add out_l, temp_l
addc out_h, temp_h
endm
ldb loop,#15
ldbse sample_0,#XIN
;Kx and Nx implementation
;+++++++++++++++++++++++++++++ FIR Calculation +++++++++++++++++++++++++++++++++
BEGIN:
irp temp_count, <0,1,2,3,4,5,6,7,8,9,10,11,12,13,14>
fir coeff_, sample_, temp_count
endm
mul temp,coeff_0,sample_0 ;h(N-1) * x(n-(N-1))
add out_l,temp_l ;accumulate
addc out_h,temp_h
shll temp,#1
ld out,temp ;save final output
sjmp fir_optz
;+++++++++++++++++++++++++++++ FIR Calculation +++++++++++++++++++++++++++++++++
;80296SA implementation
;+++++++++++++++++++++++++++++ FIR Calculation +++++++++++++++++++++++++++++++++
fir_optz:
smacz coeff,sample ;DO INITIAL MPY, INIT ACC
rpt #0eh ;REPEAT NEXT INSTR 15X
smacr coeff+2,sample+2 ;DO 15 SUCCESSIVE MAC'S
mvac YOUT,#18 ;ROTATE ACC INTO YOUT, BIT-18 = BIT-15
;+++++++++++++++++++++++++++++ FIR Calculation +++++++++++++++++++++++++++++++++
DONE:
sjmp DONE
END
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -