# Connexions

You are here: Home » Content » FIR Filtering: Exercise for TI TMS320C54x (中文版 Chinese Version)

### Recently Viewed

This feature requires Javascript to be enabled.

# FIR Filtering: Exercise for TI TMS320C54x (中文版 Chinese Version)

Summary: You will implement band-pass finite impulse-response (FIR) filters with time-domain processing.

## 引言

Figure 1
filter.asm

1	.copy "core.asm"  	; Copy in core file
2   					; This initializes DSP and jumps to "main"
3
4  FIR_len .set   8			; This is an 8-tap filter.
5
6          .sect ".data"		; Flag following as data declarations
7
8    	    .align 16			; Align to a multiple of 16
9  coef					; assign label "coeff"
10	    .copy "coef.asm"		; Copy in coefficients
11
12	    .align 16
13 firstate
14 	    .space 16*8			; Allocate 8 words of storage for
15					; filter state.
16
17	    .sect ".text"		; Flag the following as program code
18  main
19      ; Initialize various pointers
20	    stm    #FIR_len,BK		; initialize circular buffer length
21	    stm    #coef,AR2    	; initialize coefficient pointer
22	    stm	   #firstate,AR3	; initialize state pointer
23	    stm    #1,AR0		; initialize AR0 for pointer increment
24
25  loop
26      ; Wait for a new block of 64 samples to come in
27  	    WAITDATA
28
29      ; BlockLen = the number of samples that come from WAITDATA (64)
30    	    stm     #BlockLen-1, BRC	; Put repeat count into repeat counter
31    	    rptb    endblock-1		; Repeat between here and 'endblock'
32
33    	    ld	    *AR6,16, A		; Receive ch1 into A accumulator
34    	    mar     *+AR6(2)            ; Rcv data is in every other channel
35    	    ld      *AR6,16, B		; Receive ch2 into B accumulator
36    	    mar     *+AR6(2)            ; Rcv data is in every other channel
37
38    	    ld	    A,B			; Transfer A into B for safekeeping
39
40      ; The following code executes a single FIR filter.
41
42    	    sth     A,*AR3+%		; store current input into state buffer
43    	    rptz    A,(FIR_len-1)	; clear A and repeat
44    	    mac     *AR2+0%,*AR3+0%,A	; multiply coef. by state & accumulate
45
46    	    rnd     A			; Round off value in 'A' to 16 bits
47
48     ; end of FIR filter code. Output is in the high part of 'A.'
49
50    	    sth     A, *AR7+		; Store filter output (from A) into ch1
51    	    sth     B, *AR7+		; Store saved input (from B) into ch2
52
53    	    sth     B, *AR7+		; Store saved input to ch3...ch6 also
54    	    sth     B, *AR7+		; ch4
55    	    sth     B, *AR7+		; ch5
56    	    sth     B, *AR7+		; ch6
57
58  endblock:
59      b loop


filter.asm 用FIR滤波器处理从输入通道1送来的信号，然后将结果送至输出通道2，并将未经处理原始信号送至输出通道2。

## 第一部分：单通道FIR滤波器


1         .align 32             % Align to a multiple of 32
2  coef   .copy  "filter1.asm"  % Copy FIR filter coefficients
3
4         .align 32             % Align to a multiple of 32
5  state  .space 16*20          % Allocate 20 words of data space


## 第三部分：实现单通道滤波器的备选方案

AR0 需要设置成-1才能确保该代码正常工作。为什么？

### 注意:



1	mvdd	*AR2,*AR3+0%		; write x(-N/2) over x(-N)
2	sth	A,*AR2			; write x(0) over x(-N/2)
4					;   (prepare for first multiply)
5
6	rptz	B,#(FIR_len/2-1)
7	firs	*AR2+0%,*AR3+0%,COEFF
8	mar	??????? 		; Fill in these two instructions
9	mar	???????			; They modify AR2 and AR3.
10
11					; note that the result is now in the
12					;  B accumulator




1	stm	#(FIR_len/2),BK		; initialize circular buffer length
2	stm	#firstate_,AR2		; initialize location containing first
3					;   half of states
4
5	stm	#-1,AR0			; Initialize AR0 to -1
6
7	stm	#firstate2_,AR3	        ; initialize location containing last half



## Content actions

PDF | EPUB (?)

### What is an EPUB file?

EPUB is an electronic book format that can be read on a variety of mobile devices.

My Favorites (?)

'My Favorites' is a special kind of lens which you can use to bookmark modules and collections. 'My Favorites' can only be seen by you, and collections saved in 'My Favorites' can remember the last module you were on. You need an account to use 'My Favorites'.

| A lens I own (?)

#### Definition of a lens

##### Lenses

A lens is a custom view of the content in the repository. You can think of it as a fancy kind of list that will let you see content through the eyes of organizations and people you trust.

##### What is in a lens?

Lens makers point to materials (modules and collections), creating a guide that includes their own comments and descriptive tags about the content.

##### Who can create a lens?

Any individual member, a community, or a respected organization.

##### What are tags?

Tags are descriptors added by lens makers to help label content, attaching a vocabulary that is meaningful in the context of the lens.

| External bookmarks