# Connexions

You are here: Home » Content » DSP Development Environment: Introductory Exercise for TI TMS320C55x

### Lenses

What is a lens?

#### 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.

#### Affiliated with (What does "Affiliated with" mean?)

This content is either by members of the organizations listed or about topics related to the organizations listed. Click each link to see a list of all content affiliated with the organization.
• TI DSP

This module is included inLens: Texas Instruments DSP Lens
By: Texas Instruments

Click the "TI DSP" link to see all content affiliated with them.

Click the tag icon to display tags associated with this content.

#### Also in these lenses

• Lens for Engineering

This module is included inLens: Lens for Engineering
By: Sidney Burrus

Click the "Lens for Engineering" link to see all content selected in this lens.

• Real-Time DSP with MATLAB

This module is included inLens: DSP with MATLAB lens
By: Bhaskar BhattacharyaAs a part of collection: "Digital Signal Processing Laboratory (ECE 420 55x)"

"Real-Time DSP with MATLAB"

Click the "Real-Time DSP with MATLAB" link to see all content selected in this lens.

Click the tag icon to display tags associated with this content.

### Recently Viewed

This feature requires Javascript to be enabled.

### Tags

(What is a tag?)

These tags come from the endorsement, affiliation, and other lenses that include this content.

# DSP Development Environment: Introductory Exercise for TI TMS320C55x

Module by: Thomas Shen, David Jun. E-mail the authors

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.

## Introduction

This exercise introduces the hardware and software used in testing a simple DSP system. When you complete it, you should be comfortable with the basics of testing a simple real-time DSP system with the debugging environment you will use throughout the course. First, you will connect the laboratory equipment and test a real-time DSP system with pre-written 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 code. Finally, exercises are included to refresh your familiarity with MATLAB.

## Lab Equipment

This exercise assumes you have access to a laboratory station equipped with a Texas Instruments TMS320C5510A-200 digital signal processor chip mounted on a Spectrum Digital TMS320VC5510 evaluation board. The DUAL3006, a daughtercard produced by Educational DSP, is mounted on the external peripheral interface of the board to enable four-input/four-output capability. The evaluation module should be connected to a PC running Windows and will be controlled using the PC application Code Composer Studio v4.0, a debugger and development environment. We will be using a 48kHz sample rate. The DSP board can also communicate with user code or a terminal emulator running on the PC via a USB interface.

### Note:

If you are not using Code Composer Studio v4.0, the instructions on this page do not apply. Please see the revision history of this module for instructions if using CCS v3.x

In addition to the DSP board and PC, each laboratory station should also be equipped with a function generator to provide test signals and an oscilloscope to display the processed waveforms.

### Step 1: Connect cables

Use the provided BNC cables to connect the output of the function generator to input channel 1 on the DSP evaluation board. Connect output channels 1 and 2 of the board to channels 1 and 2 of the oscilloscope. The input and output connections for the DSP board are shown in Figure 1. The figure may not be up to date, so ask a TA if you need help.

Note that with this configuration, you will have only one signal going into the DSP board and two signals coming out. The output on channel 1 is the filtered input signal, and the output on channel 2 is the unfiltered input signal. This allows you to view the raw input and filtered output simultaneously on the oscilloscope. Turn on the function generator and the oscilloscope.

When you log in, two shared networked drives should be mapped to the computer: the W: drive, which contains your own private network work directory, and the V: drive, where the necessary files for ECE 420 are stored. Be sure to save any files that you use for the course to the W: drive. Temporary files may be stored in the C:\Users\netID\workspace directory; however, since files stored on the C: drive are local to each computer, and may be erased at any time, do not store course files on the C: drive. On the V: drive, the directory V:\ece420\55x\ccs4 contains the files necessary to assemble and test code on the TI DSP evaluation boards.

Although you may want to work exclusively in one or the other of lab-partners' network account, you should be sure that both partners have copies of the lab assignment assembly code.

#### Warning:

Not having the assembly code during a quiz because "it's on my partner's account" is NOT a valid excuse!
For copying between partners' directory on W: or for working outside the lab, access to your files is available. See http://www.ece.illinois.edu/cts/storage/ for instructions on how to set that up.

## The Development Environment

The evaluation board is controlled by the PC through the JTAG interface using the application Code Composer Studio. This development environment allows the user to download, run, and debug code assembled on the PC. Work through the steps below to familiarize yourself with the debugging environment and real-time system using the provided FIR filter code (Steps 3, 4 and 5), then verify the filter's frequency response with the subsequent MATLAB exercises (Steps 6 and 7).

### Step 3: Assemble filter code

#### Setup Code Composer

By default, a shortcut to CCS is available by going to Start > All Programs > Texas Instruments > Code Composer Studio v4. When CCS starts for the first time, Workspace Launcher will start because it will need to set up your workspace.

Create or make sure you have the following directory: W:\workspace\ECE420. In Workspace Launcher, hit Browse..., navigate to this folder, and make sure to check "Use this as the default and do not ask again".

#### Note:

In the future, verify that you are in the correct workspace by going to File > Switch Workspace...

#### Import Project

In CCS, go to View > C/C++ Projects. A panel will pop up on the left side of the window. Right-click somewhere in this panel and choose Import...

1. Expand "CCS" and choose "Existing CCS/CCE Eclipse Project"
2. Hit Next and browse to V:\ece420\55x\ccs4\filter
3. Check "Copy projects into workspace"

#### Build Project

Once the project is copied into your workspace, we can proceed to build it by selecting Project > Build Active Project. In a successful build, there will be zero errors and maybe a few warnings and remarks. The output file will be placed in a Debug folder within the project's directory. In this example, the executable binary code will be located at .\Debug\filter.out.

### Step 4: Verify filter execution

#### Connect to the DSP

1. Select View > Target Configurations
2. In the panel that comes up, expand Projects > filter
3. Right-click on dsk5510.ccxml and select "Launch Selected Configuration"

Once CCS connects to the DSP, select Target > Connect Target

Now, load your assembled filter file (filter.out) onto the DSP by selecting Target > Load Program. Finally, execute the code by selecting Target > Run.

The program you are running accepts input from input channel 1 and sends output waveforms to output channels 1 and 2 (the filtered signal and raw input, respectively). Note that the "raw input" on output channel 2 may differ from the actual input on input channel 1, because of distortions introduced in converting the analog input to a digital signal and then back to an analog signal. The A/D and D/A converters on the six-channel surround board operate at a sample rate of 48 kHz and have an anti-aliasing filter and an anti-imaging filter, respectively, that in the ideal case would eliminate frequency content above 24 kHz. On the basis of this information, what differences do you expect to see between the signals at input channel 1 and at output channel 2? The converters on the board are also AC coupled and cannot pass DC signals.

#### Configure Function Generator and Oscilloscope

Set the amplitude on the function generator to 1.0 V peak-to-peak and the pulse shape to sinusoidal. Adjust the function generator so that it expects a high impedance load. The sequence of button presses to accomplish this on the function generator in the lab is Shift -> Enter -> Right -> Right -> Right -> Down -> Down -> Right -> Enter.

Make sure the oscilloscope is set to 1M impedance. This can be accomplished by pressing channel 1 or 2 and then selecting 1M Ohm from the Imped menu.

Observe the frequency response of the filter by sweeping the input signal through the relevant frequency range. What is the relevant frequency range for a DSP system with a sample rate of 48 kHz?

#### Characterize Filter Response

Based on the frequency response you observe, characterize the filter in terms of its type (e.g., low-pass, high-pass, band-pass) and its -6 dB (half-amplitude) cutoff frequency (or frequencies). It may help to set the trigger on channel 2 of the oscilloscope since the signal on channel 1 may go to zero.

### Step 5: Re-assemble and re-run with new filter

Once you have determined the type of filter the DSP is implementing, you are ready to repeat the process with a different filter by including different coefficients during the assembly process. There is a second set of filter coefficients already in your project folder. In Windows Explorer, navigate to W:\workspace\ece420\filter and do the following:

• Rename coef.asm to coef1.asm
• Rename coef2.asm to coef.asm

Repeat the assembly and testing process with the new filter by repeating steps required to build (Step 3) and execute (Step 4) the code.

Just as you did in Step 4, determine the type of filter you are running and the filter's -6 dB point by testing the system at various frequencies.

### Step 6: Check filter response in MATLAB

In this step, you will use MATLAB to verify the frequency response of your filter by copying the coefficients from the DSP to MATLAB and displaying the magnitude of the frequency response using the MATLAB command freqz.

#### View Coefficients in DSP Memory

The FIR filter coefficients included in the file coef.asm are stored in memory on the DSP. To view the contents of the DSP memory, first suspend any running program by going to Target > Halt and then select View > Memory.

In the panel that comes up, there is a text box for you to type in the name of the variable that you are interested in viewing. This variable name is actually a mnemonic for a memory address. In the case of our coefficients, the mnemonic coef1 is used to point to the starting address of our coefficients. The memory content can be displayed in many different formats. In the drop-down box, choose 16-Bit Signed Int.

#### Note:

Make sure you understand where the coef1 label comes from. [Hint:] Select View > C/C++ Projects and double click on filtercode.asm to view the source code.

In this example, the filter coefficients are placed in memory in decreasing order; that is, the last coefficient, h7 h 7 , is at location coef1 and the first coefficient, h0 h 0 , is stored at coef1+7.

Now that you can find the coefficients in memory, you are ready to use the MATLAB command 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 you want to view the response of the three-tap filter with coefficients -10, 20, -10 you can use the following commands in MATLAB:

• >> h = [-10, 20, -10];
• >> freqz(h)

Note that you will have to enter eight values, the contents of memory locations coef1 through coef1+7, into the coefficient vector, h.

#### Tip:

You must divide the coefficients by 32768. Where does this scaling factor come from?

How does the MATLAB response compare with your experimental results? What might account for any differences?

### Step 7: Create new filter in MATLAB and verify

MATLAB scripts will be made available to you to aid in code development. For example, one of these scripts allows you to save filter coefficients created in MATLAB in a form that can be included as part of the assembly process without having to type them in by hand (a very useful tool for long filters). These scripts may already be installed on your computer; otherwise, download the files from the links as they are introduced.

First, have MATLAB generate a "random" eight-tap filter by typing h = gen_filt; at a MATLAB prompt. Then save this vector of filter coefficients by typing save_coef('coef.asm',fliplr(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 . They are also available at V:/ece420/55x/m_files)

The save_coef MATLAB script will save the coefficients of the vector h into the named file, which in this case is coef.asm. Note that the coefficient vector is "flipped" prior to being saved; this is to make the coefficients in h h fill DSP memory-locations coef1 through coef1+7 in reverse order, as before.

You may now re-assemble and re-run your new filter code as you did in Step 5.

Notice when you load your new filter that the contents of memory locations coef1 through coef1+7 update accordingly.

### Step 8: Modify filter coefficients in memory

Not only can you view the contents of memory on the DSP using the debugger, you can change the contents at any memory location simply by double-clicking on the location and making the desired change in the pop-up window.

#### Note:

The DSP must be in a halted state in order to overwrite the memory.

Change the contents of memory locations coef1 through coef1+7 such that the coefficients implement a scale and delay filter with impulse response:

hn=8192δn4 h n 8192 δ n 4
(1)
Note that the DSP interprets the integer value of 8192 as a fractional number by dividing the integer by 32,768 (the largest integer possible in a 16-bit two's complement register). The result is an output that is delayed by four samples and scaled by a factor of 14 1 4 . More information on the DSP's interpretation of numbers appears in Two's Complement and Fractional Arithmetic for 16-bit Processors.

#### Note:

A clear and complete understanding of how the DSP interprets numbers is absolutely necessary to effectively write programs for the DSP. Save yourself time later by learning this material before attempting Lab 1!

After you have made the changes to all eight coefficients, run your new filter and use the oscilloscope to measure the delay between the raw (input) and filtered (delayed) waveforms.

#### Tip:

Take advantage of the "Quick Measure" feature on the oscilloscope!

What happens to the output if you change either the scaling factor or the delay value? How many seconds long is a single-sample delay? Six-sample delay?

### Step 9: Test-vector simulation

As a final exercise, you will find the output of the DSP for an input specified by a test vector. Then you will compare that output with the output of a MATLAB simulation of the same filter processing the same input; if the DSP implementation is correct, the two outputs should be almost identical. To do this, you will generate a waveform in MATLAB and save it as a test vector. You will then run your DSP filter using the test vector as input and import the results back into MATLAB for comparison with a MATLAB simulation of the filter.

The first step in using test vectors is to generate an appropriate input signal. One way to do this is to use the MATLAB function 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.

Generate a sinusoidal sweep using sweep.m and save it to a DSP test-vector file using the following MATLAB commands:

• >> 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

Next, use the MATLAB conv command to generate a simulated response by filtering the sweep with the filter h h you generated using gen_filt above. Note that this operation will yield a vector of length 507 (which is n+m1 n m 1 , where n n is the length of the filter and m m is the length of the input). You should keep only the first 500 elements of the resulting vector.

• >> out=conv(fliplr(h),t); % Filter t with FIR filter h
• >> out=out(1:500); % Keep first 500 elements of out

The main.c file needs to be told to take input from memory on the DSP. Fortunately, the changes have already been made in the files. The test vector is stored in a block of memory on the DSP just like other variables. The memory block that holds the test vector is large enough to hold a vector up to 4,000 elements long. The test vector stores data for all four channels of input and from four channels of output.

To run your program with test vectors, you will need to modify main.c as well as filtercode.asm. Both are simply text files and can be edited using the editor of your preference, including WordPad, Emacs, and VI. (The changes have already been made, but please visually verify the changes are there.) Within main.c, uncomment the #define FILE_INPUT line so that your program will rewrite input from the A/D with the test vector you specified and then save the output into a block of memory.

In filtercode.asm, uncomment the .copy "testvect.asm" line. Make sure this Matlab generated file is in the same directory as filtercode.asm.

#### Note:

In TI assembly, the semi-colon ; signifies a comment.

These changes will copy in the test vector. After modifying your code, assemble it, then load and run the file using Code Composer as before. After a few seconds, halt the DSP (using the Halt command under the Target menu). How many seconds do you think it should take?

#### Saving DSP Memory to File

Next, we will save the test output file and load it back into MATLAB. We are interested in the first 500 output samples, starting at address tv_outbuf in Data memory. There are four output channels and the memory is interleaved in time. Therefore, we will have to collect 2000 (4 channels time 500 samples) memory elements.

• Select View > Memory
• Click on the "Save" icon, a green square with an angled arrow (top left in the Memory panel)
• Name the file output.dat and save filetype as TI data format
• On the next screen, use the following options:
• format: hex
• start address: tv_outbuf
• memory page: data
• length: 2000

Last, use the read_vector (available as read_vector.m) function to read the saved result into MATLAB. Do this using the following MATLAB command:

• >> [ch1,ch2,ch3,ch4] = read_vector('output.dat');

Now, the MATLAB vector 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.

#### Note:

Because of quantization error introduced in saving the test vector for the 16-bit memory of the DSP, the vector ch2 will not be identical to the MATLAB generated test vector.

After loading the output of the filter into MATLAB, compare the expected output (calculated as 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

You should also ensure that the difference between the two outputs is near zero. This can be done by plotting the difference between the two vectors:

• >> plot(out(1:length(ch1))-ch1); % Plot error signal

You will observe that the two sequences are not exactly the same; this is due to the fact that the DSP computes its response to 16 bits precision, while MATLAB uses 64-bit floating point numbers for its arithmetic. Blocks of output samples may also be missing from the test vector output due to a bug in the test vector core. Nonetheless, the test vector environment allows one to run repeatable experiments using the same known test input for debugging.

### Step 10: Closing Down

Before exiting Code Composer, make sure to disconnect properly from the DSP:

• Halt any program running on the DSP (Target > Halt)
• Disconnect from the DSP (Target > Connect will toggle between connecting and disconnecting)
Finally, make sure to return all of the cables to the wall rack.

## 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