Lab 7 DSPBEE13
Lab 7 DSPBEE13
Lab 7 DSPBEE13
Lab Instructions
This lab activity comprises of three parts: Pre-lab, Lab Exercises, and Post-Lab Viva session.
The lab report shall be uploaded on LMS three days before next scheduled lab. The Pre-lab tasks
should be completed before coming to the lab and hard copy of Pre-lab session should be
deposited with teacher/lab engineer at start of the lab for necessary evaluation. Alternatively, the
reports can be submitted in PDF format on LMS.
The students should perform and demonstrate each lab task separately for step-wise evaluation
(please ensure that course instructor/lab engineer has signed each step after ascertaining its
functional verification)
Only those tasks that completed during the allocated lab time will be credited to the students.
Students are however encouraged to practice on their own in spare time for enhancing their
skills.
Lab Report Instructions
All questions should be answered precisely to get maximum credit. Lab report must ensure following
items:
Lab objectives
MATLAB codes
Results (graphs/tables) duly commented and discussed
Conclusion
The DSK also has four user-programmable DIP switches and four LEDs that can be used to control and
monitor programs running on the DSP. All features of the DSK are managed by the CCS, which is a
complete integrated development environment (IDE) that includes an optimizing C/C++ compiler,
assembler, linker, debugger, and program loader. The CCS communicates with the DSK via a USB
connection to a PC. In addition to facilitating all programming aspects of the C6713 DSP, the CCS can
also read signals stored on the DSP’s memory, or the SDRAM, and plot them in the time or frequency
domains.
1.2 Warmup
1.2.1 QUICK TESTS OF THE DSK ( ON POWER ON AND USING CCS )
Connect the USB cable from the DSK6713 to the computer and then connect power to the DSK6713. If
this is the first time the DSK has been connected to the computer, you may see Windows install the
device driver software:
You can also check that the DSK is recognized by going into the Device Manager and looking for "SD
USB Based Debug Tools". You should see a "Spectrum Digital TMS320C6713 DSK" listed as a correctly
installed device. If not, then CCS v6 has probably not been installed correctly.
Now start CCS v6 by double-clicking on the desktop icon (or navigating through the start menu). You
may be prompted to select a workspace. If so, choose a directory that you would like to use as your
workspace and click "OK". If the TI Resource Explorer window comes up, just close it. Eventually, you
should get to the main CCS v6 window, which should look something like this
This is the "normal" edit view of CCS v6 where you will manage projects, build and debug your code,
and interact with the DSK. Since this is the first time we are using CCS v6, we must set up a "target
configuration" for the DSK6713.
From the normal view of CCS v6, click on "Window->Show View->Target Configurations" to expose the
target configurations panel.
When you first use CCS v6, there won't be any target configurations. So we will set one up for the
DSK6713. Note that you only need to do this once. Right click on the "User Defined" folder in the target
configurations panel and select "New Configuration".
A new panel should appear where you set some options for this DSK6713.ccxml target configuration. In
the connection pull down menu, select "Spectrum Digital DSK-EVM-eZdsp onboard USB Emulator". In
the device selector, select "DSK6713"
Click "Save".
Now expand the "User Defined" target configurations folder by clicking on the little triangle next to the
folder. You should see the new DSK6713.ccxml target configuration in there. Right click on it and select
"Launch Selected Configuration". You should see some USB enumeration as CCS v6 talks with the DSK
and then you should see something like this window.
Now click on "Run->Connect Target" (or press Ctrl+Alt+C). You should then see a window something
like this The message "GEL StartUp Complete" in the Console means that CCS v6 is successfully talking
with the DSK.
1.2.2 Sine Wave Generation Using Eight Points with DIP Switch Control (
sine8_LED )
This example generates a sinusoidal analog output waveform using a table – lookup method. More
importantly, it illustrates some of the features of CCS for editing source files, building a project,
accessing the code generation tools, and running a program on the C6713 processor. The C source file
sine8_LED.c listed in Figure 1.2 is included in the folder sine8_LED .
The program statement while(1) within the function main() creates an infinite loop. Within that loop, the
state of DIP switch #0 is tested and if it is pressed down, LED #0 is switched on and a sample from the
lookup table is output. If DIP switch #0 is not pressed down then LED #0 is switched off. As long as DIP
switch #0 is pressed down, sample values read from the array sine_table will be output and a sinusoidal
analog output waveform will be generated via the left - hand channel of the AIC23 codec and the LINE
OUT and HEADPHONE sockets. Each time a sample value is read from the array sine_table , multiplied
by the value of the variable gain , and written to the codec, the index, loopindex , into the array is
incremented and when its value exceeds the allowable range for the array( LOOPLENGTH - 1 ), it is
reset to zero.
FIGURE 1.2. Sine wave generation program using eight points with DIP switch control ( sine8_LED.c ).
Each time the function output_left_sample() , defined in source file C6713dskinit.c , is called to output a
sample value, it waits until the codec, initialized by the function comm_poll() to output samples at a rate
of 8 kHz, is ready for the next sample. In this way, once DIP switch #0 has been pressed down it will be
tested at a rate of 8 kHz. The sampling rate at which the codec operates is set by the program statement
Uint32 fs = DSK6713_AIC23_FREQ_8KHZ;
One cycle of the sinusoidal analog output waveform corresponds to eight output samples and hence the
frequency of the sinusoidal analog output waveform is equal to the codec sampling rate (8 kHz) divided
by eight, that is, 1 kHz.
These steps assume that you have correctly installed and configured CCS v6. You should be able to
connect to the DSK and see something like the following window before proceeding.
Click on "File->New->CCS Project". If this is the first time using CCS v6, you may have to click "File-
>New->Other" and then select CCS project. The following window should appear and set values
according to figure.
This is where you name and configure your project. Here we named the project "sine8_LED", told CCS
This is what it should look like after you've set up the project container.
You might have some other panels visible, but the Project Explorer panel should show the sin8_LED
project as "Active" and should show the C6713.cmd file.
So far, we just have an empty project container with no code. Now you can copy or move sin8_LED.c
from LMS a, vectors_poll.asm and c6713dskinit.c from (c:\ti\Support) into your project directory using
Project->add files option.Here is what CCS v6 should look like after it recognizes that you moved the two
source files into the project directory.
If we try to build the project now, we will get some errors because (among other things) CCS v6 doesn't
know how to find the CSL and BSL header files and libraries. We'll first tell CCS v6 where to find the
header files. Click on "Project->Properties". Drill down to "Build / C6000 Compiler / Include Options" in
the left sidebar:
This is where we will configure CCS v6 to find the appropriate header files. Note that we can add
C:\ti\Support
C:\ti\DSK6713\DSK6713\c6000\dsk6713\include
C:\ti\C6xCSL\include.
We now need to tell CCS v6 to include the CSL and BSL library files in the project. Drill down to
"Build / C6000 Linker / File Search Path" in the left sidebar:
Note that we can include library files directly in the project by pressing the button with the green plus
sign.
Press the button with the green plus sign to add the CSL library
Usually, the CSL library is in C:\ti\C6xCSL\lib_3x\csl6713.lib. Click "OK".
Press the button with the green plus sign to add the BSL library
Usually, the BSL library is in C:\ti\DSK67 13\c6000\dsk6713\lib\dsk6713bsl.lib. Click "OK".
Part 5: Tell CCS what to use for stack and heap sizes
You could now compile the project, but you would get some warnings about not explicitly setting the
stack and heap sizes (CCS v6 will just go with some default values). We would like to get rid of these
warnings. To do this, drill down to "Build / C6000 Linker / Basic Options" in the left sidebar and put in
There is still one more thing to fix before CCS v6 will cleanly compile the project. Drill down to "Build /
C6000 Compiler / Advanced Options / Runtime Model Options" in the left sidebar and set the "Constant
access model" and "Data access model" both to "Far":
While the project will compile with the current settings, the compiler will not use instructions optimized
for the TMS320C6713 chip unless we tell it to do so. Drill down to "Build / C6000 Compiler / Processor
Options" in the left sidebar and set the "Target processor version" to "6713" (no quotes):
Drill down to "Build / C6000 Compiler / Advance options/predefined symbols" and press the button with
the green plus sign add type in CHIP_6713 and press OK as show in figure below
If you've followed all of the steps above, you should be able to build the project without errors or
warnings. Click on the hammer button or "Project->Build All". You should see something like this:
In the Debug window, press the Run/Resume button. Try it. You can halt the code anytime by pressing
the Suspend button (looks like pause). When the DSP is running, you should hear music. When the DSP
is halted, you should not hear music.
2. Change the number of samples stored in the lookup table to four. By changing the lines that read
#define LOOPLENGTH 8
void main()
{
comm_poll(); //init DSK,codec,McBSP
DSK6713_LED_init(); //init LED from BSL
DSK6713_DIP_init(); //init DIP from BSL
while(1) //infinite loop
{
if(DSK6713_DIP_get(0)==0) //=0 if DIP switch #0 pressed
{
DSK6713_LED_on(); //turn LED #0 ON
output_left_sample(sine_table[loopindex++]*gain); //output sample
if (loopindex >= LOOPLENGTH) loopindex = 0; //reset table index
}
else DSK6713_LED_off(0); //turn LED off if not pressed
} //end of while(1) infinite loop
} //end of main
A different DIP switch can be used to control whether or not a sinusoid is generated by changing the
value of the parameter passed to the functions DSK6713_DIP_get(), DSK6713_LED_on(), and
DSK6713_ LED_off() . Suitable values are 0, 1, 2, and 3. Two sliders can readily be used, one to change
the gain and the other to change the frequency. A different signal frequency can be generated, by
changing the incremental changes applied to the value of loopindex within the C program (e.g., stepping
through every two points in the table). When you exit CCS after you build a project, all changes made to
the project can be saved.