<< Chapter < Page | Chapter >> Page > |
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
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 and
core.asm into it. Then use MATLAB to generate two 20-tap FIR
filters. The first filter should pass signals from 4 kHz to 8kHz; the second filter should pass from 8 kHz to 12 kHz. For
both filters, allow a 1 kHz transition band on each edge ofthe filter passband. To create these filters, first convert
these band edges to digital frequencies based on the 44.1 kHzsample rate of the system, 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 sure you reverse the vectors of
filter coefficients before you save them.) Also save yourfilters as a MATLAB matrix, since you will 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.
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:
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
Notification Switch
Would you like to follow the 'Dsp laboratory with ti tms320c54x' conversation and receive update notifications?