<< Chapter < Page | Chapter >> Page > |
In this section, you will implement the 20-tap FIR filter. Edit
filtercode.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_len1
to
20.
FIR_len1
is set using the
.set
directive, which assigns a number to a symbolic name. You will
need to change this to
FIR_len1 .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
TMS320C55x 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 coef1 .copy "coef1.asm" % Copy FIR filter coefficients3
4 .align 32 % Align to a multiple of 325 inputBuffer .space 16*20 % Allocate 20 words of data space
Assemble your code, load the output file, and run. Ensure that it is has the correct frequency response. After you have verifiedthat this code works properly, proceed to the next step.
So far you have been working exclusively in your
filtercode.asm
file, where the
FIR filtering is taking place. In this part, you will be exposed to some of the C code that is required to setup the hardware peripherals. Your goal will be to write C code to change how the filtered output and raw input are sent to the output channels.
You may have noticed that your assembly code seems to automatically run every time a new input sample is ready to be processed. How does the system know to run the assembly routine when new samples are waiting? The answer lies in an interrupt , a signal sent by the hardware alerting the processor that new samples are ready to be processed.
Open
main.c
, and find the function named
HWI_RINT0
.
This is the function that is called each time the DSP receives a hardware interrupt,signaling the presence of new input samples. You can see that
input[0]
and
input[1]
receive the samples from the four input channels, and then
filter()
is called, beginning your assembly routine in
filtercode.asm
.
After the assembly function returns back into the C code,
output[0]
and
output[1]
hold your four output samples.
output[0]
variable is a 32-bit integer. Channel 1 and 2 outputs are expected in the top 16 bits and bottom 16 bits, respectively. Likewise, channels 3 and 4 are expected in the top and bottom 16 bits of
output[1]
.Notification Switch
Would you like to follow the 'Ece 420 fall 2013' conversation and receive update notifications?