📄 firc10.asm
字号:
;========================================================================
;
; File Name :firc10.asm
;
; Originator :Digital Control Systems Group
; Texas Instruments
;
; Description :This file contain source code for FIR Filter
; Implementation Using Circular buffer for Fixed order Filter = 10
;
; Date : 17/1/2001
;======================================================================
;
;
; Routine Name : Generic Function
; Routine Type : C Callable
;
; Description :
; void FIRFILT_CORD10_calc(FIRFILT_CORD10_handle)
;
; This routine implements the non-recursive difference equation of an
; all-zero filter(FIR), using Circular Buffer technique
; All the coefficients of all-zero filter are assumed to be less than 1 in magnitude.
;
;======================================================================
;
; Difference Equation :
;
; y(n)=H(0)*x(n)+H(1)*x(n-1)+H(2)*x(n-2)+....+H(10)*x(n-10)
;
; where
; y(n)=output sample of the filter at index n
; x(n)=input sample of the filter at index n
;
; Transfer Function :
;
; Y(z) -1 -2 -9 -10
; ----- = h(0) + h(1) z + h(2) z + ... +h(N-1) z + h(N) z
; X(z)
;
; Network Diagram :
; dbuffer[0] dbuffer[1] dbuffer[2] dbuffer[10}
; Input -1 x(n-1) -1 x(n-2) x(n-10)
; x(n) >------o----z---->-o----z---->-o--- - ->- - o
; | | | |
; | | | |
; | | | |
; v H(0) v H(1) v H(2) v H(10)
; | | | |
; | | | | output
; |---->-----(+)---->----(+)-- - -> - (+)-----> y(n)
;
; Symbols Used :
; H(0),H(1),H(2),...,H(10) : filter coefficients
; x(n-1),x(n-2),...,x(n-10) : filter states
; x(n) : filter input
; y(n) : filter output
;==============================================================================
; Function Input: This function accepts the handle of the below structure
;
; typedef struct
; {int *coeff_ptr; /* Pointer to Filter co-efficient array */
; int brindex; /* BR Index */
; int order; /* Order of the filter */
; int *dbuffer_ptr; /* Delay buffer pointer */
; int input; /* Input data */
; int output; /* Output data */
; void (*init)(void *) /* Pointer to init fun */
; void (*calc)(void *); /* Pointer to the calculation function */
; }FIRFILT_CORD10;
;
; Filter input (x) :
; x(n) = | s.fff ffff | ffff ffff |
;
; Filter coefficients(h[]):
; h(k) for k=0,1,2,...,10
; = | s.fff ffff | ffff ffff | are stored as shown below.
;
;
; |----------|
; AR3-----> | H(0) |
; |----------|
; | H(1) |
; |----------|
; | H(2) |
; |----------|
; | . |
; | . |
; |----------|
; | H(8) |
; |----------|
; | H(9) |
; |----------|
; | H(10) |
; |----------|
; filter coefficients
;
; Implicit inputs(dbuffer[]):
; To compute the present output y(n), inputs x(n-i) for i=1,2,...10
; are needed. These are stored in the filter states buffer
;
; Filter order(n):
; This member of the structure holds the order of the filter
;
; Filter output(y):
; y(n)= | s.fff ffff | ffff ffff | Q15 Format
;====================================================================
; Function Local Frame
;====================================================================
; |_______|
; |_______|<- Stack Pointer (FP+1) <---AR1
; |_______|<- Register to Register Tfr & Computation (FP)
; |_______|<- Old FP (FP-1)
; |_______|<- Return Address of the Caller (FP-2)
; |_______|<- Formal parameter FIRFILT_GEN_handle (FP-3)
;======================================================================
; Symbolic Constant
ORDER .set 10
; Module definition for external referance
.def _FIRFILT_CORD10_calc
__fir_calc_frs .set 00001h ; Local frame size for this routine
_FIRFILT_CORD10_calc:
POPD *+ ; Store the Return Address in stack
SAR AR0,*+ ; Store the Caller's Frame Pointer
SAR AR1,*
LAR AR2,*+,AR2 ; ARP=AR2, AR2=FP, AR1=FP+1
SETC SXM
SETC OVM
SBRK #3 ; ARP=AR2, AR2=FP-3 points to the input argument
LAR AR2,* ; ARP=AR2, AR2= FIRFILT_CORD10_handle->*coeff_ptr
LAR AR3,*+ ; ARP=AR2, AR2->brindex & AR3=coeff_ptr->coeff[N]=H(N)
LAR AR0,*+ ; ARP=AR2, AR2->order & AR0=brindex
MAR *+ ; ARP=AR2, AR2->dbuffer_ptr
LAR AR4,*,AR4 ; ARP=AR4, AR4->dbuffer_ptr, AR2->dbuffer_ptr
; AR4=dbuffer_ptr pointing to the oldest sample
LACL #0 ; Clear ACC
LT *BR0-,AR2 ; ARP=AR2, AR2->dbuffer_ptr
SAR AR4,*+,AR3 ; ARP=AR3, AR2->input & store back the dbuffer_ptr
.loop ORDER-1
MPY *-,AR4 ; ARP=AR5
LTA *BR0-,AR3 ; ARP=AR3
.endloop
MPY *-,AR2 ; ARP=AR2, AR2->output
LTA *+,AR3 ; ARP=AR3, TREG=input, AR2->output
MPY *,AR2 ; ARP=AR2, AR2->output
APAC ;
SACH * ; 32 bit of ACC is added with itself to get Q31 result
ADDH *
SACL *
ADDS * ; ARP=AR2, AR2->output
ADD #1,15 ; Round the result
SACH *- ; ARP=AR2, AR2->input
LACL *,AR4
SACL *,0,AR1
CLRC OVM
SBRK #(__fir_calc_frs+1) ; Clear the local frame
LAR AR0,*- ; Retrive Caller's frame pointer
PSHD * ; Push the return address to TOS
RET ; Return to the caller
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -