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

EE289RT_Lab1

Embed Size (px)

DESCRIPTION

OMAP Audio delay manual

Citation preview

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

• Configurable 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 (ExternalMemory Interface). The SDRAM, Flash and CPLD are all connected to the bus. EMIF signals are alsoused for daughter cards. The DSP interfaces to analog audio signals through an on-board AIC3106 codecand 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 implementlogic that ties the board components together. The OMAP includes two LEDs and two 8 position DIPswitches which allow for interactive feedback.

Simulink communicates with Code Composer Studio through Simulink Embedded Coder. Code ComposerStudio 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 signalprocessor IC. First, you will create a model of the system in Matlab/Simulink, then you will use tools tocompile the model, download it, and run it on the OMAP-L138 board, which contains a TI TMS320C6748DSP 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 CCSwhen you tell it to generate code for the model, and CCS will automatically compile the code to an executable(.out file). 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 usingFile→ New → Model in the library browser.

5. Save the model using the File/Save As pulldown. You can name it audio delay or another descriptivename. 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 CodeComposer Studio v5 (makefile generation only)”. From the middle one, select “OMAP-L138/C6748EVM”. The bottom one should be grayed out and read “OMAPL138” when the other two are setproperly.

9. Now click Yes in the pop-up to initialize the model configuration 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 modelyou’re 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 five blocks in your model. You need to connect them and set some parameters in someof the blocks. The Target Preferences block doesn’t have any connections, it just defines the settings for theDSP board.

16. Put the ADC, Delay, Sum, and DAC blocks in a line from left to right. This order is the signal flowfor 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 twoblocks.

4

19. Hold the Ctrl key down and click on the Sum block, then click on the DAC block. There should berightarrows 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 aninch long. The line is dashed red because it isn’t connected to anything.

21. Release the mouse button, then click again at the unattached end of the rightarrow, hold the buttondown, 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 byclicking 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 clickOK. You’ll 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 matchthe ADC block. Don’t change the settings.

24. Save the model.

Connect the Hardware

You’ll 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 tobuild the model.

Use caution when handling the DSP board; the ICs can easily be damaged bystatic charge that you cannot sense. Handle the board as little as possible, anddon’t 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 touchthe 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 theOMAP-L138. If that isn’t sufficient, 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 nearthe 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 it’s doing in building themodel. A Windows command prompt will also open with text; this happens when Matlab is donecreating the C code and calls CodeComposer to compile it. Do not close this window or type anythinginto it.

5

28. When CodeComposer is done building the model, you should see a line in the command prompt thatsays “gmake: *** [execute] Error 1”. This is perfectly normal, don’t worry. The code compiled fine,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 somethinglike “audio delay ticcs”, assuming you named your model “audio delay”. In this directory you will findall the files generated by Matlab, notably the C code.

30. Look in the sub-directory “CustomMW”. This is where you’ll find the end result: your Simulink modeldistilled 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 theback of the bench.

32. Connect the USB cable between the PC and the OMAP. Note: use the mini-USB connector on theleft-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 volumelow. If the speakers don’t 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 runningon 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 Configurations”.

39. Open the “User Defined” folder in this pane. You should see “OMAP L138 Simulink.ccxml”. This isa CodeComposer debug session configuration file.

40. Right-click on it and select “Launch Selected Configuration”. You will now see CodeComposer’s fulldebugging environment.

41. On the OMAP board, find the large power switch in the lower-right-hand corner and flip it on. Youshould 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 C6748core and mDDR memory.

45. Click Run → Load → Load Program, and browse to the .out file generated earlier. Loading theprogram may take a few minutes.

46. Once it’s loaded you’ll 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 themodel. Snap your fingers 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 onthe 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 willstill be running on the DSP board. Test the board using the microphone and speakers. (Note that theprogram 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 5This 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 filter

4. The Integer Delay block is in Discrete library of the Simulink blockset. The Gain block is in theCommonly Used library of the simulink blockset. The ADC and DAC blocks for the OMAP-L138 arein the Embedded Coder/Embedded Targets/Processors/Texas Instruments C6000/OMAP-L138 blocktree.

5. From the Embedded Coder/Embedded Targets group, add the Target Preferences block. This blockis 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 field is set to “Columns asChannels (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 effectout 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 first 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