You are on page 1of 4

ELE 792 Digital Signal ProcessingLaboratory

Fall 2011

LAB 2: Implementation of Finite Impulse Response Filters on the TMS320C6713 DSK Completion Date: October 1821, 2011

Objective

The objective of Lab 2 is to study the inner workings of Finite Impulse Response (FIR) lters and to investigate the various real-time implementation options on the TMS320C6713 DSK. Lab 2 will also demonstrate the use of multiple FIR lters by implementing a simple scrambler/de-scrambler scheme.
Prelab Assignment

1. Read Chapter 4, Section 7 of the lab reference text which provides several programming examples using C and assembler code. You should be familiar with Chapter 4, Sections 16 as they provide a theoretical background on FIR lters covered in earlier courses and briey in ELE 792. 2. Learn how to design frequency selective digital FIR lters using Matlab (type fdatool at Matlab prompt). The utility function dsk r67.m writes the Matlab generated lter coefcients into a le that can then be easily incorporated into your C code for implementation on the TMS320C6713 DSK. You can nd this utility function in the Support directory, e.g. X:\ele792\src\Support\dsk r67.m.
Project Files

In Lab 2 you will primarily use the source and project les in the r, rprn, r2ways, notch2 and scrambler directories. These directories also contain numerous lter coefcient les (les with .cof extension) that allow you test various lters. Alternatively, you can design your own lters in Matlab, export the Matlab generated lter coefcients into coefcient les and test them on the DSK. The following notes provide further information on the source les in the above mentioned project directories. Project r: The le r.c in the r directory shows a basic FIR lter implementation where the lter coefcients are in oating-point format (the coefcient le is ave5f.cof, note the f at the end of the le name) and the calculations are carried out in oating point format before the output sample y[n] is converted into a short format for the output sample function. After each output sample y[n] is calculated the lter state buffer where the previous input samples x[n], x[n 1], . . . x[n M] are stored, are shifted such that the most recent input sample will always be the rst element of the lter state buffer. Project rprn: The le rprn.c in the rprn directory is the same oating-point implementation of a basic FIR lter as before. However, it uses internally generated pseudo-random noise samples as the lter input. This implementation is helpful if you want to observe the frequency response of the lter using only a spectrum analyzer (or a digital scope with a spectrum analyzer module).
1 of 4

Fall 2011

ELE 792 Digital Signal processingLaboratory

Project r2ways: The le r2ways.c in the r2ways directory shows two different implementations of an FIR lter. Method A is the xed-point implementation of the method used in r.c, whereas Method B uses pointers to implement a circular buffer for the lter state buffer. The use of pointers improves the coding efciency which is crical in real-time implementations. Important: Method B implementation of the FIR lter provided in r2ways.c includes a minor error. Please download the corrected version of the le r2ways new.c accessible at the Laboratory/Lab 2 link on Blackboard. Project notch2: The le notch2.c in the notch2 directory provides a xed-point implementation of a cascade connection of two notch lters. It can be easily modied to implement a single notch lter in oating-point format. Project scrambler: The le scrambler.c in the scrambler directory provides a oatingpoint implementation of a scrambler that uses an internal sinusoid generator based on the look-up table method. During the time allocated for Lab 2 we will not have time to discuss the specics of all implementations in other FIR lter projects shown in the lab reference text. However, several of these projects, and in particular, the rcasm, rcasmfast, rcirc and rcirc ext projects, provide examples that are very informative as they show how C and assembler code can be mixed within the same project for coding efciency.
Problems to Solve

1. Design a FIR lowpass lter with the following specications:

Sampling frequency . . . . . . . . . . . . . . . . . . . . . . . . Passband cut-off frequency . . . . . . . . . . . . . . . . . . . Maximum passband deviation from unity . . . . . . . Stopband cut-off frequency . . . . . . . . . . . . . . . . . . . Minimum stopband attenuation . . . . . . . . . . . . . . .

: : : : :

48 10 1 15 60

kHz kHz dB kHz dB

a. Prepare a CCS project for a oating-point implementation of the lter on the DSK based on Method B shown in the r2ways.c le. Verify that the real-time implementation of the lter conforms to the lter specications. b. Design and implement the same lter using Matlab/Simulink; build the project through the Simulink interface and run it on the DSK. 2. Consider the FIR notch lter: Hnotch (z) = 1 2 cos 0 z 1 + z 2 with 0 = /4 as the notch frequency.
2 of 4

(1)

ELE 792 Digital Signal ProcessingLaboratory

Fall 2011

a. Prepare a CCS project for a oating-point implementation of the FIR notch lter with transfer function given in Equation (1). Verify that the real-time implementation of the notch lter conforms to specications. b. Create a GEL slider to adjust the notch frequency for 0 < 0 < . 3. In this problem you will work with the scrambler project given in Example 4.11 (lab reference text, pp. 193196). a. Study the source code given in the le scrambler.c to have a good understanding of how the scrambler is implemented. You can test the scrambler using a sinusoid from a function generator fed to the input of the scrambler (and observing the scrambler output waveform on the scope); in addition, you may also connect a microphone to the input of the scrambler/DSK and listen to the scrambled output using your ear-/headphones. You can also connect the output of one DSK running the scrambler code to the input of another DSK running the de-scrambler (which is identical to the scrambler) code, and observe/listen to the de-scrambled output. b. Design and implement the scrambler using Matlab/Simulink; build the project through the Simulink interface and run it on the DSK. c. Implement the scrambler and the de-scrambler on the same DSK as shown in Figure (1). You can implement the system in Figure (1) either in C or in Matlab/Simulink.

input

scrambled output
Left Scrambler Left

ADC Right De-Scrambler

DAC Right

de-scrambled output

TMS320C6713 DSK

Figure 1: Implementation of the scrambler and the de-scrambler on the same DSK.

d. Design a GEL slider that will change to frequency of the oscillator used in the descrambler. Change the frequency and observe the effects of mismatch between the scrambler and de-scrambler oscillator frequencies.

3 of 4

Fall 2011

ELE 792 Digital Signal processingLaboratory

Evaluation

Points: Problem 1 is worth 5 points, Problems 2 and 3 are worth 10 points each. How to Submit Your Code? During the course of Lab 2 you will generate several C source code les, *.c, possibly some coefcient les, *.cof, and Simulink model les, *.mdl. Your source code les should always be well commented. You can also add informative text to your Simulink models. Place all your les into an archive (zip-le only, please!). By the completion deadline, submit your archive le using the command: submit ele792 lab2 mycodearchive where mycodearchive is the name of the archive le which contains all your code. If you prefer to submit your les individually then you have to repeat the above submit command for each le. Please note that to use the submit command you have to be logged on on one of computers on our departmental network booted to Linux and to enter the above command from a terminal window.
References

1. A.V. Oppenheim and R.W. Schafer, Discrete-Time Signal Processing, 3rd Edition, Pearson Higher Education Inc., 2010. 2. R. Chassaing and D. Reay, Digital Signal Processing and Applications with the TMS320C6713 and TMS320C6416 DSK, 2nd Edition, Wiley IEEE Press, Chp. 4, pp. 146207, 2008. 3. Circular Buffering on TMS320C6000, Texas Instruments Application Report, SPRA645A, April 2001. (Available from Blackboard.)

4 of 4

You might also like