You are on page 1of 9

E E 2 8 9 REAL TIME LAB March 15, 2013

LABs 1 & 2 - USING the C674x DSK


LAB 1. OMAP-L138 Audio Delay
Due: Friday March 29, 2013
Introduction
A PC is required to run Code Composer Studio which is required to compile and download code to (run on)
the DSP. (Note: This is the same Lab. as Lab.1 in the Real-Time set of Labs.)
Figure 1: Typical Lab setup for C674x DSK.
1
DSP Board Highlights
Figure 2: OMAP-L138 DSK block diagram
Texas Instruments TMS320C6748 DSP operating at 375 MHz
Texas Instruments ARM926EJ-S MPU operating at 375 MHz
An AIC3106 stereo codec
128 KB of shared RAM
256 MB of mDDR RAM
2 user accessible LEDs and 16 DIP switches
Congurable boot options
Standard expansion connectors for daughter card use
JTAG emulation through on-board JTAG emulator with USB host interface or external emulator
Single voltage power supply (+5V)
2
Functional Overview of DSP Board
The DSP on the OMAP-L138 interfaces to on-board peripherals through a 32-bit wide EMIF (External
Memory Interface). The SDRAM, Flash and CPLD are all connected to the bus. EMIF signals are also
used for daughter cards. The DSP interfaces to analog audio signals through an on-board AIC3106 codec
and two 3.5 mm audio jacks (line in and line out).
A programmable logic device called a CPLD (Complex Programmable Logic Device)is used to implement
logic that ties the board components together. The OMAP includes two LEDs and two 8 position DIP
switches which allow for interactive feedback.
Simulink communicates with Code Composer Studio through Simulink Embedded Coder. Code Composer
Studio communicates with the OMAP through an embedded JTAG emulator with a USB host interface.
Matlab communicates with CCS via Link for Code Composer Studio.
Figure 3: Real-Time Workshop
Simple Audio Systems
In this Lab 1 you will build a simple audio system that can run on a Texas Instruments digital signal
processor IC. First, you will create a model of the system in Matlab/Simulink, then you will use tools to
compile the model, download it, and run it on the OMAP-L138 board, which contains a TI TMS320C6748
DSP IC.
Software tools used:
Matlab (R2012b)
Simulink 8.0
3
CodeComposer Studio v5.1 (from TI)
Code Composer Studio (CCS) includes a compiler for the OMAP-L138 DSP. Matlab/Simulink starts CCS
when you tell it to generate code for the model, and CCS will automatically compile the code to an executable
(.out le). You must then manually load this executable using the CodeComposer Studio environment.
Create the Simulink Model
1. Log in to the PC and bring up Matlab R2012b. Note that earlier versions of Matlab will not work.
2. Change the working directory to M:\Matlab\Work\
3. Bring up the Simulink library browser by typing simulink at the Matlab prompt.
4. Start a new model by clicking on the New Model icon in the Simulink library browser, or using
File New Model in the library browser.
5. Save the model using the File/Save As pulldown. You can name it audio delay or another descriptive
name. Save it in the M:/matlab/work/ directory on your network drive.
6. In the Simulink library browser, open the Embedded Coder library group and select Embedded Targets
7. From the Embedded Targets library, drag the Target Preferences block to your empty model.
8. A window will pop up with three drop-down menus. From the top one, select Texas Instruments Code
Composer Studio v5 (makele generation only). From the middle one, select OMAP-L138/C6748
EVM. The bottom one should be grayed out and read OMAPL138 when the other two are set
properly.
9. Now click Yes in the pop-up to initialize the model conguration parameters for the board.
10. In the Simulink library browser, expand the following subgroups in a tree: Processors, Texas Instru-
ments C6000, and OMAP-L138/C6748 EVM.
11. From the OMAP-L138/C6748 EVM library, drag an ADC block and a DAC block into the model
youre building.
12. Go to the DSP System Toolbox library group and select Signal Operations.
13. From the Signal Operations library, drag the Delay block into the model.
14. Open the Simulink library group and select Commonly Used Blocks. (At the top)
15. From the Commonly Used Blocks library, drag the Sum block into the model.
Now you should have ve blocks in your model. You need to connect them and set some parameters in some
of the blocks. The Target Preferences block doesnt have any connections, it just denes the settings for the
DSP board.
16. Put the ADC, Delay, Sum, and DAC blocks in a line from left to right. This order is the signal ow
for the model.
17. Highlight the ADC block by clicking once on it.
18. Hold the Ctrl key down and click on the Delay block. You should see an rightarrow connect the two
blocks.
4
19. Hold the Ctrl key down and click on the Sum block, then click on the DAC block. There should be
rightarrows connecting all the blocks.
20. Click and hold on the second input to the Sum block, and move the mouse to create a line about an
inch long. The line is dashed red because it isnt connected to anything.
21. Release the mouse button, then click again at the unattached end of the rightarrow, hold the button
down, then drag over to the rightarrow between the ADC and the delay and release the mouse button.
Now there is a path from the ADC to the summing block. (If you have to delete a line, highlight it by
clicking on it, then use the delete key.)
22. Double-click on the delay block. Set the delay to 2048 samples. Leave all other settings alone and click
OK. Youll see the notation on the block change to z
2048
.
23. You can double-click on the DAC block to see that the settings for sample rate and word length match
the ADC block. Dont change the settings.
24. Save the model.
Connect the Hardware
Youll need the following hardware in order to continue with the lab:
OMAP-L138 DSP board
microphone
speakers
USB cable to connect the PC to the OMAP
The OMAP-L138 does not need to be connected to the PC in order to invoke Code Composer Studio to
build the model.
Use caution when handling the DSP board; the ICs can easily be damaged by
static charge that you cannot sense. Handle the board as little as possible, and
dont let anything fall on or brush against the board.
Once the USB cable is connected between the PC and the OMAP-L138, if you have to touch
the board, you can ground yourself on the metal shroud on the USB connector on the board.
Hold the board by the metal shroud while connecting the microphone and speakers to the
OMAP-L138. If that isnt sucient, try to touch just the edge of the board.
The functions of the two jacks are silkscreened onto the board, but the font is small, so look carefully near
the jacks to see which jack has which function.
25. In the Simulink model window, click the drop-down box that says Normal and set it to External.
26. Now click the Build Model button, or use the Code C/C + +Code Build Model menu.
27. You should now see in the Matlab command window text telling you what its doing in building the
model. A Windows command prompt will also open with text; this happens when Matlab is done
creating the C code and calls CodeComposer to compile it. Do not close this window or type anything
into it.
5
28. When CodeComposer is done building the model, you should see a line in the command prompt that
says gmake: *** [execute] Error 1. This is perfectly normal, dont worry. The code compiled ne,
unless there were other errors along the way. You may now also close the Windows command prompt.
29. If you look in the directory where you saved the model, you should see a new folder called something
like audio delay ticcs, assuming you named your model audio delay. In this directory you will nd
all the les generated by Matlab, notably the C code.
30. Look in the sub-directory CustomMW. This is where youll nd the end result: your Simulink model
distilled down into one executable made to run on the OMAP-L138.
31. Orient the board so that the power connection is on the right and the audio connectors are toward the
back of the bench.
32. Connect the USB cable between the PC and the OMAP. Note: use the mini-USB connector on the
left-hand side, near the audio ports.
33. Connect the microphone to the LINE IN jack.
34. Connect the speakers to the LINE OUT jack. Make sure the speakers are powered, but set the volume
low. If the speakers dont work, try headphones.
35. Plug in the power supply and connect the power cable to the OMAP.
36. Keep the microphone away from the speakers, to avoid acoustic feedback once the program is running
on the OMAP.
Running the Model on the DSP Hardware
Now you should be ready to run the model.
37. Open CodeComposer Studio.
38. On the right-hand side, you should see a pane that says Target Congurations.
39. Open the User Dened folder in this pane. You should see OMAP L138 Simulink.ccxml. This is
a CodeComposer debug session conguration le.
40. Right-click on it and select Launch Selected Conguration. You will now see CodeComposers full
debugging environment.
41. On the OMAP board, nd the large power switch in the lower-right-hand corner and ip it on. You
should see a green LED indicating that the power is on.
42. Click Run Connect Target.
43. Now click Retry on the pop-up message.
44. Click Scripts FrequencySettings Core 300MHz mDDR 150MHz. This will initialize the C6748
core and mDDR memory.
45. Click Run Load Load Program, and browse to the .out le generated earlier. Loading the
program may take a few minutes.
46. Once its loaded youll see the disassembled code in the middle-right.
6
47. Now click Run Resume or press the F8 key to run the code.
48. Once you see **starting the model** in the CCS message pane, you should be able to try the
model. Snap your ngers or tap the microphone and listen for the output.
Q1: About how long is the delay?
Q2: How long would you expect it to be given the sample rate and the delay block parameter settings?
49. This very small project required a lot of code. In CCS, you can see the disassembled code that runs on
the DSP chip. Refer back to earlier (step 29) to see the C code. Particularly, look at audio dealy.c.
50. To show that the code is running on the DSP and not on the PC, close Matlab. The program will
still be running on the DSP board. Test the board using the microphone and speakers. (Note that the
program will be lost once the power is removed from the board or CodeComposer is closed.)
Q3: Describe in a few lines, the purpose of Code Composer Studio.
7
E E 2 8 9 REAL TIME LAB March 22, 2013
LAB 2. Building the Audio Reverberation Model
Due Friday April 5
This is a continuation of LAB 1. OMAP-L138 Audio Delay.
1. Open Simulink.
2. Create a new model by selecting File New Model from the Simulink menu bar.
3. Use Simulink blocks to create the following model.
Figure 4: Real time reverberation lter
4. The Integer Delay block is in Discrete library of the Simulink blockset. The Gain block is in the
Commonly Used library of the simulink blockset. The ADC and DAC blocks for the OMAP-L138 are
in the Embedded Coder/Embedded Targets/Processors/Texas Instruments C6000/OMAP-L138 block
tree.
5. From the Embedded Coder/Embedded Targets group, add the Target Preferences block. This block
is not connected to any other block in the model.
6. Double-click on the gain blocks, click the Signal Attributes tab, and change the Output Data Type to
int16.
7. Double-click on the delay block and ensure that the Input Processing eld is set to Columns as
Channels (Frame Based).
8. Build and run the model (using the Incremental Build button on the model toolbar).
9. Speak into the microphone connected to the board. The model should generate a reverberation eect
out of the speakers, delaying and echoing the words you speak into the mike.
8
Q1: Describe in one short paragraph what you learned in this Lab.
The rst version of this Lab was by Paul Beliveau. Revised 3/29/2012 by GM. Further revised by Rudy Raab on
12/5/2012 to adapt the original C6713 lab to the new OMAP-L138 DSK boards. Revised 3/8/13 GM.
9