Generating a Sine Wave Using the Hardware and Software
Tools for the TI TMS320C6748 DSP
Laboratory home page
Aim of the experiment
The aim of this experiment is to
- become familiar with the TMS320C6748 hardware and software tools
by outputting sinusoidal signals from the C6748 board and
- explore the design tradeoffs in signal quality vs. implementation
complexity in computing values of sinusoidal signals.
Sinusoidal waveforms will be output by using two different methods:
- Interrupts
- Direct Memory Access
Equipment to be checked out
- Two BNC - stereo pin (DSP)cables
- C6748 DSP Experimenter's Kit
All the above equipment can be checked out from the checkout counter
on the second floor.
The above list of equipment is the equipment required per work station.
Reading assignment
- Real-Time Digital Signal Processing from MATLAB to
C with the TMS320C6x DSPs (Jan. 2012) by
Thad B. Welch, Cameron H. G. Wright and Michael G. Morrow,
- Chapters 5 and 6
- Appendices A, B, C and D
- Software Receiver Design by
C. Richard Johnson, Jr., William A. Sethares and Andrew Klein
- Sections 2.1-2.5
- Sections 3.1, 3.2, 3.4 and 3.6
- Course reader
Downloads
Recitation slides
Part 1 and
Part 2
by Ms. Debarati Kundu, The University of Texas at Austin
Lab instructions
Part 1 and
Part 2
by Ms. Debarati Kundu, The University of Texas at Austin
Updated EDMA files as a zip archive
(see 7-zip for a free zip program)
for week 2 of lab
Design tradeoffs in computing
sinusoidal signals by Prof. Brian L. Evans,
The University of Texas at Austin
(see slides 1-8 to 1-15)
LabVIEW transmitter demonstration by Dr. Zukang Shen to show how labs 1-6 fit together
Overview Slides
by Prof. Steven Tretter, University of Maryland (from Jan. 2008 lab manual)
Debugging and Troubleshooting Tips
When connecting the USB cable from the PC to the C6748 DSP board, please
use the USB port on the opposite side of the board from the power connector.
Here are
troubleshooting
tips for Code Composer Studio v5.
Here are troubleshooting tips if you see an incorrect sinusoid on the
oscilloscope:
- Be sure that the output impedance of the signal generator is set
to be high-Z.
- Check the implementation of the difference equation or lookup
table method.
One can use the printf function to print out the values
of samples they generated so they can check the correctness.
- Be sure that the sampling rate is set properly in both the
Interrupt Service Routine (ISR) and the configuration file.
The sampling frequency specified in isr file is only used for
computation.
- Check to see if interrupt is working.
Even though the interrupt is not working, the oscilloscope could
still show sinusoidal-like noise.
This can be easily checked by measuring the magnitude of the
waveform, and knowing that noise should have a very small magnitude.
- Be sure that in the generatetable function in the EDMA starter code,
you have cast floating point calculations to Uint32.
This is needed because the samples will be received by the McASP,
which processes integers.
- In the second week of lab 2, students must not reset the board
between the first part (talkthrough using EDMA) and the second part
(sinusoidal generation using EDMA).
- Be sure to declare the array holding the lookup table as a
global variable.
Lab Report
Please turn in one lab report per two-person team. Include the following sections in the Lab #2 report and in future reports:
- Introduction: Briefly explain the theory and algorithms behind
the programs that you wrote.
The recitation slides might help you in writing this section.
- Methods: Describe the steps you took to implement the algorithms
in your own words.
This section should be brief (1-2 paragraphs).
- Results: Present the results you obtain for each task on the
assignment sheet.
This section should include illustrative oscilloscope screenshots of the
DSP algorithms in action.
Also include any code that you wrote or modified.
Please do not include all of the boilerplate code from the textbook.
- Discussion: In this section, discuss the takeaway from each lab.
You can mention any intuition that you developed.
Also mention any problems that you faced and how you rectified them.
- Assignment questions: Please answer the questions asked in the
assignment.
Discrete-Time Resonator Implementation
The Welch, Wright and Morrow book has C code in Section 5.4.4 to
generate a sine wave using a discrete-time resonator.
The difference equation to generate sin(w0 n) u(n) is
y[n] = sin(w0) x[n-1] + 2 cos(w0) y[n-1] - y[n-2]
and the input signal x[n] is the discrete-time impulse.
At n = 0, we have x[n] = 1, x[n-1] = 0, y[n-1] = 0, y[n-2] = 0, which gives y[n] = 0)
At n = 1, we have x[n] = 0, x[n-1] = 1, y[n-1] = 0, y[n-2] = 0, which gives y[n] = sin(w0)
At n = 2; we have x[n] = 0, x[n-1] = 0, y[n-1] = sin(w0), y[n-2] = 0, which gives y[n] = 2 cos(w0) sin(w0) = sin(2 w0) when using the following trigonometric identity:
sin(x) cos(y) = 1/2 ( sin(x-y) + sin(x+y) )
Issue #1.
The code in Section 5.4.4 starts the difference equation at n = 2.
As a result, the code in the book will generate a shifted version
of sin(w0 n) u(n).
When w0 = pi/2, a shift in the sine wave by two samples will generate a negated sine wave:
sin(pi/2 (n - 2)) = sin((pi/2) n - pi) = -sin((pi/2) n)
When f0 = 2 kHz and fs = 8 kHz, we have
w0 = 2 pi f0 / fs = pi/2, and hence,
the shifted sine wave generated by the code in Welch, Wright and
Morrow looks like -sin(w0 n).
Issue #2.
The code in the book is inefficient and difficult to follow.
To improve efficiency and clarity, one could change
float y[3] = {0 , 1 , 0} ;
....
CodecDataOut.Channel[LEFT] = A * sinf(theta) * y[0]; // scale
to
float y[3] = {0 , sinf(theta) , 0} ;
....
CodecDataOut.Channel[LEFT] = A * y [0]; // scale
And, for additional efficiency, one could replace sinf(theta)
and cosf(theta)
with constants because theta
is a constant.
There is no reason to call the sinf and cosf functions because
the values can be computed offline for a constant theta.
And, the whole point of using the difference equation in the first
place is to avoid calling a math routine.
Useful references
Texas Instruments TMS320C6748 processor, board, and tools
Back to the course home page
Next Experiment
Previous Experiment