Summary: This exercise introduces the hardware and software used in the course. By the end of this module, you should be comfortable with the basics of testing a simple real-time DSP system with Code Composer Studio, the debugging environment we will be using throughout the semester. First you will connect the laboratory equipment and test a real-time DSP system with provided code to implement an eight-tap (eight coefficient) finite impulse response (FIR) filter. With a working system available, you will then begin to explore the debugging software used for downloading, modifying, and testing your code. Finally, you will create a filter in MATLAB and use test vectors to verify the DSP's output.
Example Hardware Setup![]() Figure 1 |
DOS prompt window and create a new
directory to hold the files, then copy filter.asm, coef1.asm, coef2.asm, core.asm, and vectcore.asm into your
directory.
coef1.asm called
"coef.asm" and assemble the filter code by typing
asm filter at the DOS prompt.
The assembling process first includes the FIR filter
coefficients (stored in coef.asm) into the
assembly file filter.asm, then compiles the
result to produce an output file containing the executable
binary code, filter.out. Reset option from the Debug menu
in the Code Composer application.
CPU
Registers option from the View menu,
then select CPU Register. This will open a
sub-window at the bottom of the Code Composer application
window that displays several of the DSP registers. Look
for the PMST register; it must be set to the
hexadecimal value FFE0 to have the DSP
evaluation board work correctly. If it is not set
correctly, change the value of the PMST
register by double-clicking on the value and making the
appropriate change in the Edit Register
window that comes up.
Load Program from the
File menu. Finally, reset the DSP again, and
execute the code by selecting Run from the
Debug menu.
coef2.asm. Make a copy of
coef2.asm and call it coef.asm.
asm instruction at
the DOS prompt and repeating the steps
required to execute the code discussed in Step 4.
freqz.
coef.asm are stored in memory on the DSP
starting at location (in hex) 0x1000, and
each filter you have assembled and run has eight
coefficients. To view the filter coefficients as signed
integers, select the Memory option from the
View menu to bring up a Memory Window
Options box. In the appropriate fields, set the
starting address to 0x1000 and the format to
16-Bit Signed Int. Click "OK" to open a
memory window displaying the contents of the specified
memory locations. The numbers along the left-hand side
indicate the memory locations.
0x1000 and the first
coefficient,
0x1007.
freqz to view
the filter's response. You must create a vector in MATLAB
with the filter coefficients to use the freqz
command. For example, if we want to view the response of
the three-tap filter with coefficients -10, 20, -10 we can
use the following commands in MATLAB:
h = [-10, 20, -10];plot(abs(freqz(h)))0x1000 through
0x1007, into the coefficient vector,
h = gen_filt; at a MATLAB prompt.
Then save this vector of filter coefficients by typing
save_coef('coef.asm',flipud(h));. Make sure
you save the file in your own directory. (The scripts
that perform these functions are available as gen_filt.m and save_coef.m.)
coef.asm. Note that the coefficient vector
is "flipped" prior to being saved; this is to make the
coefficients in
0x1000
through 0x1007 in reverse order, as before.
0x1000 through
0x1007 update accordingly.
0x1000 through 0x1007 such that
the coefficients implement a filter
sweep (available as sweep.m) to generate a sinusoid that
sweeps across a range of frequencies. The MATLAB function
save_test_vector (available as save_test_vector.m can
then save the sinusoidal sweep to a file you will later
include in the DSP code.
>> t=sweep(0.1*pi,0.9*pi,0.25,500); % Generate a frequency sweep
>> save_test_vector('testvect.asm',t); % Save the test vector
conv command to generate
a simulated response by filtering the sweep with the
filter
gen_filt above. Note that
this operation will yield a vector of length 507 (which is
>> out=conv(h,t) % Filter t with FIR filter h >> out=out(1:500) % Keep first 500 elements of out
filter.asm to use the
alternative "test vector" core file, vectcore.asm. Rather than
accepting input from the A/D converters and sending output
to the D/A, this core file takes its input from, and saves
its output to, memory on the DSP. The test vector is
stored in a block of memory on the DSP evaluation board
that will not interfere with your program code or data.
.etext section. See Core File: Introduction to Six-Channel
Board for TI EVM320C54 for more information on the
DSP memory sections, including a memory map.filter.asm. The assembly source
is simply a text file and can be edited using the editor of your
preference, including WordPad, Emacs, and VI. Replace the first
line of the file with two lines. Instead of:
.copy "core.asm"
.copy "testvect.asm" .copy "vectcore.asm"
.copy directive is required.
Halt command under the
Debug menu) and verify that the DSP has
halted at a branch statement that branches to itself. In
the disassembly window, the following line should be
highlighted: 0000:611F F073 B 611fh.
0x8000 in program memory. Do this
by choosing File->Data->Save... in Code
Composer Studio, then entering the filename
output.dat and pressing Enter.
Next, enter 0x8000 in the Address field of
the dialog box that pops up, 3000 in the
Length field, and choose Program from the
drop-down menu next to Page. Always make sure
that you use the correct length (six times the length of
the test vector) when you save your results.
read_vector (available as read_vector.m) function to read
the saved result into MATLAB. Do this using the following
MATLAB command:
>> [ch1, ch2] = read_vector('output.dat');
ch1 corresponds to the
filtered version of the test signal you generated. The
MATLAB vector ch2 should be nearly identical
to the test vector you generated, as it was passed from
the DSP system's input to its output unchanged. ch2 will not be identical to the
MATLAB generated test vector.out above) and the output of the filter (in
ch1 from above). This can be done graphically
by simply plotting the two curves on the same axes; for
example:
>> plot(out,'r'); % Plot the expected curve in red >> hold on % Plot the next plot on top of this one >> plot(ch1,'g'); % Plot the expected curve in green >> hold off
>> plot(out-ch1); % Plot error signal
out=out(1:500)
above.
Comments, questions, feedback, criticisms?