<< Chapter < Page Chapter >> Page >
You will implement band-pass finite impulse-response (FIR) filters with time-domain processing.

Introduction

In this exercise, you will program in the DSP's assembly language to create FIR filters. Begin by studying theassembly code for the basic FIR filter filter.asm .

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 applies an FIR filter to the signal from input channel 1 and sends the resulting output to outputchannel 1. It also sends the original signal to output channel 2.

First, create a work directory on your network drive for the files in this exercise, and copy filter.asm from v:\ece320\54x\dsplib to your work directory (this is thesame file you worked with in Lab 0). Then, use MATLABto generate two 20-tap FIR filters. The first filter should pass signals from 4 kHz to 8 kHz; the second filter shouldpass from 8 kHz to 12 kHz. For both filters, allow a 1 kHz transition band on each edge of the filter passband. Tocreate these filters, first convert these band edges to digital frequencies based on the 44.1 kHz sample rate of thesystem, then use the MATLAB command remez to generate this filter; you can type help remez for more information. Use the save_coef command to save each of these filters into different files. (Make sureyou reverse the vectors of filter coefficients before you save them.) Also save your filters as a MATLAB matrix, since youwill need them later to generate test vectors. This can be done using the MATLAB save command. Once this is done, use the freqz command to plot the frequency response of each filter.

Part 1: single-channel fir filter

For now, you will implement only the filter with a 4 kHz to 8 kHz passband. Edit filter.asm to use the coefficients for this filter by making several changes.

First, the length of the FIR filter for this exercise is 20, not 8. Therefore, you need to change FIR_len to 20. FIR_len is set using the .set directive, which assigns a number to a symbolic name. You will need to change this to FIR_len .set 20 .

Second, you will need to ensure that the .copy directive brings in the correct coefficients. Change the filename to point to the file that contains the coefficientsfor your first filter.

Third, you will need to modify the .align and .space directives appropriately. The TI TMS320C54x DSP requires that circular buffers, which are usedfor the FIR filter coefficient and state buffers, be aligned so that they begin at an address that is a multiple of a powerof two greater than the length of the buffer. Since you are using a 20-tap filter (which uses 20-element state andcoefficient buffers), the next greater power of two is 32. Therefore, you will need to align both the state andcoefficient buffers to an address that is a multiple of 32. (16-element buffers would also require alignment to a multipleof 32.) This is done with the .align command. In addition, memory must be reserved for the state buffer. Thisis done using the .space directive, which takes as its input the number of bits of space to allocate. Therefore, to allocate 20 words of storage, usethe directive .space 16*20 as shown below:

Get Jobilize Job Search Mobile App in your pocket Now!

Get it on Google Play Download on the App Store Now




Source:  OpenStax, Ece 320 - spring 2003. OpenStax CNX. Jan 22, 2004 Download for free at http://cnx.org/content/col10096/1.2
Google Play and the Google Play logo are trademarks of Google Inc.

Notification Switch

Would you like to follow the 'Ece 320 - spring 2003' conversation and receive update notifications?

Ask