⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 glms.asm

📁 汇编代码 c54x的自适应滤波器(LMS)的实现
💻 ASM
字号:
;************************************************************************
daptive filter using the LMS instruction                     *
*
;************************************************************************
        .mmregs
	.def	begin, N, Beta

N	.set	16		; the LMS adaptive filter will have N taps
REF	.set	300h		; Reference chanel port address
IN	.set	100h		; Input chanel port address
OUT	.set	200h		; Output chanel port address

COUNT	.set	2000		; process .250 seconds of data


REFERENCE    .usect	"REF", N        ; allocate space for ref buffer
COEFFICIENTS .usect	"FILTER", N     ; allocate space for adaptive filter

	.bss	ERROR, 3, 1	; make sure that these vars on same page
Beta	.set	ERROR + 1	; beta is a variable so it can be changed
				; during processing
INPUT	.set	ERROR + 2


	.sect  "vectors"        ; set up a reset vector
	 B     begin

        .text
        NOP
begin   SSBX    SXM             ; sign extention is on
	SSBX	FRCT		; We are performing Q15*Q15 mult.
				; Need left shift of one so
				; Q31 is in accumulator. Turn FRCT on.
	RSBX	OVM		; let the accumulator over flow

	LD	#ERROR, DP	; set up data page
	STM	#INPUT, AR5	;
	STM	#REFERENCE, AR4 ;
	STM	#COUNT, AR6	; loop counter

	ST	#300, Beta	; Beta can be changed during processing
				; Beta is initialized to .009
	STM	#N, BK		; set the circular buffer size register
	STM	#1, AR0 	; load index increment value

LOOP
	STM	#COEFFICIENTS, AR3
ADAPT
	LD	#0, B		; clear B
	STM	#N-2, BRC	; We will do one tap before start of rptb
	LD	ERROR, T	; error(0) = Beta*error(-1)
	RPTBD	LMS_END-1
	 MPY	*AR4, A 	; A = error(-1)*x(-n)
				; note: past error is used for update
	 LMS	*AR3, *AR4+0%	; A = A + *AR3<<16 + 2^15
				; B = B + *AR3 x *AR4

	  ST	A, *AR3+	; save filter coefficient
	  ||MPY *AR4, A 	; error(-1) * x(-(n-1))
				; note: past error is used for update
	  LMS	*AR3, *AR4+0%	; A = A + *AR3<<16 + 2^15
				; B = B + *AR3 x *AR4

LMS_END
	ST	A, *AR3 	; finish up last coefficient update
	||SUB	*AR5, A 	; A = (*AR5)<<16 - B,  the new error
	STH	A, ERROR	; save the new error

	PORTW	ERROR, OUT	; output the error signal

	LD	Beta, T 	; Update the error
	MPY	ERROR, A	; A = ERROR(0)*Beta
	STH	A, ERROR

	PORTR	IN, *AR5	; EC on this input signal

	BANZD	LOOP, *AR6-	;
	 PORTR	REF, *AR4+0%	; reference signal read

; BANZ takes effect here


DONE	B	DONE		; processing complete

        .end

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -