EXPERIMENT 1 SIMPLE CALCULATIONS written by Neal Glover (nealglover@uky.campus.mci.net) Anthony Reeves (acrv@msg.ti.com) Kevin Donohue (donohue@engr.uky.edu) University of Kentucky Electrical Engineering Department Fall 2001: Upgraded for the c31 by Vijay Venkatesh, Chun Guan and Geethavani Goli REFERENCES DSKD Starter Kit Manual TMS320CXX Users Guide EQUIPMENT AND MATERIALS DSKD Starter Kit and Software Personal Computer RS232-C Interface Cable 9 Vac Power Supply (for the DSK) INTRODUCTION The purpose of this experiment is to familiarize you with generating, assembling, and running programs using the DSK assembler and debugger. This will be primarily through the generation of simple arithmetic calculations. Some of the instructions that you will be referring to are ADDI3,MPYI3, LDF,FLOAT FIX,SUBF,STF,FIX,MPFY3 PROCEDURE 1. With the power turned off, connect your board to the PC RS232-C port on the computer. Connect the 9 Vac adapter to the board and plug into an outlet. Turn on the PC and change to the directory containing the DSK software. 2. We will begin by providing you with a template which you can use to generate your source code for calculations. Copy the file lab1_header.asm. Open the text file and study the outline. Should you have any questions about the structure refer to the DSK User's Guide. 3. After studying the outline, edit the text file placing sufficient comments next to each instruction to show what the line of source code is for. The comment should not describe the instruction as in the Users Guide, but it should indicate the purpose of the instruction as it relates to the overall program.It may be helpful to assemble and single step through the program to see what is happening. Should you find yourself returning to the same instruction again and again, determine why, and temporarily comment out that portion of the code. 4. Subsequent procedures will require that this program be modified. Therefore, after assembling and running each program, be sure to maintain hard copies of the .asm file and the .dsk files for your lab report. Do this for each procedure where changes are made to the source code. 5. Modify the sample program to add "val1" to "val2" and store the result in "rslt." 6. Insert code to add .9813 to .8735 using the DSP.Store only the integer part of the result and calculate the error between storing only the integer part and the whole floating point result. 7. Modify the program from step 7 to multiply "num1f" by "num2f" and store the result. 8. Initialize five values in data memory to scaled versions of .25, .5, .75, .9, and 0. Multiply the first three values by .9 and sum these products together.Do you have to worry about overflow? Why or why not? 9. Initialize the following values in data and program memory. Multiply the first four values in data memory by their associated values in program memory, sum the products, and store the integer portion of the result. Do this using one instruction as opposed to performing separate multiplies and adds. This instruction should appear only once in the code, and it will require additional instructions to make it work as desired. (You will have to use indexed addressing). Program Memory Data Memory .346 .75 .189 .3125 .407 .25 .501 .50 .782 .59375 1.00 .9375 .123 .875 .885 .078125 10. You wish to implement the following equation on the DSP. y(n) = h(0)x(n-3) + h(1)x(n-2) + h(2)x(n-1) + h(3)x(n) This is a calculation which will typically be repeated many times over (for a large number of samples n). Only the four samples needed at any given moment are stored and, after each iteration of the calculation, a new sample is read in and the oldest thrown away. Since this is a common DSP operation there is an instruction which handles much of the work involved. Identify this instruction and modify the code from problem 11 to perform one iteration of this calculation on the following data. Program Memory Data Memory h(0) = .346 x(n-3) = .75 h(1) = 1.0 x(n-2) = .3125 h(2) = .501 x(n-1) = .50 h(3) = .885 x(n) = .078125