Application specific Programming of the Texas Instruments ...

12
1 Application specific Programming of the Texas Instruments TMS320C6711 using Simulink An Overview of Application specific Programming of the Texas Instruments TMS320C6711 using Simulink Amit Prakash Singh IDD V E&C (Wireless Communications) Introduction The TMS320C67x DSPs (including the TMS320C6711, TMS320C6711B, TMS320C6711C, TMS320C6711D devices) compose the floating-point DSP family in the TMS320C6000 DSP platform. The C6711, C6711B, C6711C, and C6711D devices are based on the high-performance, advanced very-long-instruction-word (VLIW) architecture developed by Texas Instruments (TI), making these DSPs an excellent choice for multichannel and multifunction applications. The steep learning curve one needs to go through, before any significant use of this instrument can be made, makes it desirable for me to share the knowledge acquired in this area, in course of my Masters Project. The C6711 DSK has been discontinued and now C6713 DSK with more advanced capabilities has taken its place but the same principles apply and this document can be used with the newer DSK as well. About the DSK 6711 The Texas instruments TMS320C6711 DSP kit provides an extremely sophisticated set of hardware and software support tools for the real time signal processing. The DSK board includes the 6711 floating point digital signal processor and a 32 bit codec AD 535 for input and output. The basic system consists of an analog-to- digital converter (ADC) to capture an input signal. The resulting digital representation of the captured signal is then processed by DSP and output through a digital-to-analog converter. Code Composer Studio software provided by Texas Instruments is used for writing into 6711 kit.

Transcript of Application specific Programming of the Texas Instruments ...

Page 1: Application specific Programming of the Texas Instruments  ...

1 Application specific Programming of the Texas Instruments TMS320C6711 using Simulink

An Overview of Application specific Programming of the Texas Instruments TMS320C6711 using Simulink

Amit Prakash SinghIDD V E&C (Wireless Communications)

IntroductionThe TMS320C67x DSPs (including the TMS320C6711, TMS320C6711B, TMS320C6711C, TMS320C6711D devices) compose the floating-point DSP family in the TMS320C6000 DSP platform. The C6711, C6711B, C6711C, and C6711D devices are based on the high-performance, advanced very-long-instruction-word (VLIW) architecture developed by Texas Instruments (TI), making these DSPs an excellent choice for multichannel and multifunction applications. The steep learning curve one needs to go through, before any significant use of this instrument can be made, makes it desirable for me to share the knowledge acquired in this area, in course of my Masters Project. The C6711 DSK has been discontinued and now C6713 DSK with more advanced capabilities has taken its place but the same principles apply and this document can be used with the newer DSK as well.

About the DSK 6711The Texas instruments TMS320C6711 DSP kit provides an extremely sophisticated set of hardware and software support tools for the real time signal processing. The DSK board includes the 6711 floating point digital signal processor and a 32 bit codec AD 535 for input and output. The basic system consists of an analog-to-digital converter (ADC) to capture an input signal. The resulting digital representation of the captured signal is then processed by DSP and output through a digital-to-analog converter. Code Composer Studio software provided by Texas Instruments is used for writing into 6711 kit.

Figure 1: A block diagram of the DSK

1.8V Power Supply16M SDRAM 128K FLASH Daughter Card I/F(EMIF Connector)

ParallelPort I/F

PowerJack

PowerLED

3.3V Power SupplyJTAG Header

EmulationJTAG Header

Reset

Line Level Output (speakers)Line Level Input (microphone)

16-bit codec (A/D & D/A)Three User LEDs

User DIPswitches

‘C6711DSP

D. Card I/F(Periph Con.)

TMS320C6711

Page 2: Application specific Programming of the Texas Instruments  ...

2 Application specific Programming of the Texas Instruments TMS320C6711 using Simulink

Figure 2: DSK Connections

Power on Self Test There are three LEDs to provide the user with feedback from the test procedure. The test program (stored in the FLASH memory, code available on the DSK CD-ROM)

runs every time DSK is powered on and reset.

Test LED 3 LED 2 LED 1 Description

0 0 0 0 Start state

1 0 0 1 DSP internal SRAM test

2 0 1 0 External SDRAM test

3 0 1 1 DSP McBSP0 loop back test

4 1 0 0 External codec read/write test

5 1 0 1 External codec tone generation test

6 1 1 0 External LED and DSP timer test

7 1 1 1 Unused – available for future test use

B L I N K A L L All tests completed successfully

Page 3: Application specific Programming of the Texas Instruments  ...

3 Application specific Programming of the Texas Instruments TMS320C6711 using Simulink

Resetting the DSK

Figure 3: Various Modes of resetting the DSK

Programming the DSK with Simulink Target for TI C6000 integrates Simulink® and MATLAB® with Texas Instruments eXpressDSP™ tools. The software collection helps to develop and validate digital signal processing designs from concept through code. Target for TI C6000 consists of the TI C6000 target that automates rapid prototyping on theC6000 hardware targets. Target for TI C6000 uses C code generated by Real-Time Workshop® and the TI development tools to build an executable file for your intended processor.

The Real-Time Workshop build process loads the specified machine code to the board and runs the executable file on the digital signal processor. Target for TI C6000 uses Simulink to model digital signal processing algorithms from blocks in the Signal Processing Blockset, and then uses Real-Time Workshop to generate (or build) ANSI C code targeted to the Texas Instruments DSP development boards or Texas Instruments Code Composer Studio Integrated Development

TMS320C6711

Apply PowerPOST runs

CCS ResetMenu selection:DebugDSP ResetResets ‘C6711 DSPCauses bootloadfrom FLASH which overwrites internal memory

Absolute ResetOn rare occasions you might have to:Pull power jackPull parallel port

Reset PushbuttonDon’t push when CCSis runningDoes not force FULLsystem resetTo fully reset board, pull power plug

Power On Self Test (POST)Counts 1 - 74:

mic input spkr out5:

sinewave spkr outDon’t start CCS until end (all 3 LEDs flash at the end)If switches are set to 0100, a fast version of POST is run

Page 4: Application specific Programming of the Texas Instruments  ...

4 Application specific Programming of the Texas Instruments TMS320C6711 using Simulink

Environment (CCS IDE). Target for TI C6000 takes the generated C code and uses Texas Instruments (TI) tools to build specific machine code depending on the TI board used.

The build process downloads the targeted machine code to the selected hardware and runs the executable on the digital signal processor. After downloading the code to the board, the digital signal processing (DSP) application runs automatically on your target.

All the features provided by Code Composer Studio (CCS), such as tools for editing, building, debugging, code profiling, and project management, work to help develop applications using MATLAB, Simulink, Real-Time Workshop, and the supported hardware. When this target is used, the build process creates a new project in Code Composer Studio and populates the project with the files the project requires.

An Example with Simulink: Audio Reverberation Model The demonstration model name is c6711dskafxr.mdl (already available in MATLAB) as shown in the next figure. Open this model by entering c6711dskafxr at the MATLAB prompt. To run this model you need a microphone connected to the Mic In connector on your C6711 DSK, and speakers and an oscilloscope connected to the Line Out connector on your C6711 DSK. To test the model, speak into the microphone and listen to the output from the speakers. You can observe the output on the oscilloscope as well. To download and run your model on your C6711 DSK, complete the following tasks:

Use Simulink blocks, Signal Processing Blockset blocks, and blocks from other blocksets to create your model application.

Add Target for TI C6000 blocks that let your signal sources and output devices communicate with your C6711 DSK—the C6711 DSK ADC and C6711 DSK DAC blocks that you find in Target for TI C6000 c6000lib blockset.

Add the C6711DSK target preferences block from the Target Preferences library to your model. Verify and set the block parameters for your hardware. In most cases, the default settings work fine.

Set the configuration parameters for your model, including Solver parameters such as simulation start and solver options. Real-Time Workshop options such as target configuration and target compiler selection

Build your model to the selected target .Test your model running on the target by changing the input to the target and observing the output from the target. The target for this tutorial is your C6711 DSK installed on your PC.

Building the Audio Reverberation ModelTo build the model for audio reverberation, follow these steps:

Start Simulink. Create a new model by selecting File > New > Model from the Simulink menu bar.

Page 5: Application specific Programming of the Texas Instruments  ...

5 Application specific Programming of the Texas Instruments TMS320C6711 using Simulink

Use Simulink blocks and Signal Processing Blockset blocks to create the following model.

Figure 4: Simulink Model

Now add the C6711 DSK blocks to the model

Figure 5: Simulink Model with C6711/13 blocks

Configuring Target for TI C6000 BlocksTo configure Target for TI C6000 blocks in your model, follow these steps:

1 Click the C6711 DSK ADC block to select it.

2 Select Block Parameters from the Simulink Edit menu.

3 Set the following parameters for the block:

• Clear the Stereo check box.• Select the +20 dB mic gain boost check box.

From the list, set Sample rate to 8000.

• Set Codec data format to 16-bit linear.

Page 6: Application specific Programming of the Texas Instruments  ...

6 Application specific Programming of the Texas Instruments TMS320C6711 using Simulink

• For Output data type, select Double from the list.• Set Scaling to Normalize.• Set Source gain to 0.0.• Enter 64 for Samples per frame.

4 For C6711 DSK ADC source, select Mic In.

5 Click OK to close the C6711 DSK ADC dialog box.

6 Now set the options for the C6711 DSK DAC block.

• Set Codec data format to 16-bit linear.• Set Scaling to Normalize.• For DAC attenuation, enter 0.0.• Set Overflow mode to Saturate.

7 Click OK to close the dialog box.

8 Click the C6711DSK Target Preferences block.

9 Select Block Parameters from the Simulink Edit menu.

10 Verify the parameter settings for the C6711 DSK target.

Setting Simulink Configuration ParametersAfter you have designed and implemented your digital signal processing model in Simulink, complete the following steps to set the configuration parameters for the model:

1 Open the Configuration Parameters dialog box and set the appropriate options on the Solver category for your model and for Target for TI C6000.

• Set Start time to 0.0 and Stop time to inf (model runs without stopping). Generated code does not honor this setting if you set a stop time. Set this to inf for completeness.

• Under Solver options, select the fixed-step and discrete settings from the lists• Set the Fixed step size to Auto and the Tasking Mode to Single Tasking

Ignore the Data Import/Export, Diagnostics, and Optimization categories in the Configuration Parameters dialog box. The default settings are correct for your new model.

Setting Real-Time Workshop Target Build OptionsTo configure Real-Time Workshop to use the correct target files and to compile and run your model executable file, you set the options in the Real-Time Workshop category of the Configuration Parameters dialog box. Follow these steps to set the Real-Time Workshop options to target your C6711 DSK:

1 Select Real-Time Workshop on the Select tree.

Page 7: Application specific Programming of the Texas Instruments  ...

7 Application specific Programming of the Texas Instruments TMS320C6711 using Simulink

2 In Target selection, click Browse to select the system target file for C6000 targets—ccslink_grt.tlc. It may already be the selected target. Clicking Browse opens the System Target File Browser.

3 On the System Target File Browser, select the system target file ccslink_grt.tlc and click OK to close the browser. Real-Time Workshop updates the Template makefile and Makecommand options with the appropriate files based on your system target file selection.

4 From the Select tree, choose Link for CCS to specify code generation options that apply to the C6711 DSK target.

5 Under Code Generation, select the Inline run-time library functions option. Clear the other options.

6 Keep the default setting for the options in Project options.

7 Under Target Selection, verify that Export IDE link handle to base workspace is selected and provide a name for the handle (optional).

8 Change the category on the Select tree to Hardware Implementation.

9 Check that Byte ordering is set to Little endian.

10 Change the category again to Link for CCS.

11 Set the following Real-Time Workshop run-time options:

• Build action: Build_and_execute.• Interrupt overrun notification method: Print_message.

Building and Executing Your Model on Your C6711 DSKAfter you set the configuration parameters and configure Real-Time Workshop to create the files you need, you direct Real-Time Workshop to build, download, and run your model executable on your target:

1 Change the category to Real-Time Workshop on the Configuration Parameters dialog box.

2 Clear Generate code only and click Build to generate and build an executable file targeted to your C6711 DSK.

When you click Build with Build_and_execute selected for Build action, the automatic build process creates an executable file that can be run by the C6711 DSP on your C6711 DSK, and then downloads the executable file to the target and runs the file.

3 To stop model execution, click the Reset C6711 DSK block or use the Halt option in CCS. You could type halt from the MATLAB command prompt as well.

Another Example: Finding an Unknown FrequencyThere are 2 parts to this example.

Page 8: Application specific Programming of the Texas Instruments  ...

8 Application specific Programming of the Texas Instruments TMS320C6711 using Simulink

Part 1 : Setting up the circuit and executing the algorithm on DSP.

Part 2 : Exchanging values between DSP and PC.

The Signal generator is tuned to generate a sine wave of any frequency between 500 and 1000 Hz. Then this signal of unknown frequency is fed into the DSP through its’ Audio In port. The algorithm is executed on the DSP board. The frequency calculated by the board will be found to exactly match the frequency of the Signal.

There are quite a few ways to find the time-period / frequency of an unknown signal. We shall show the DSP implementation of one such technique.

Suppose the guessing range is within 500 to 1000 Hz. This would correspond to a range in time-period (1/fs) of (1/1000 = ) 1 msec to ( 1/500 = ) 2 msec. Since DSK 6711 supports a sampling frequency of 8000 Hz, the range in time-period would correspond to: -

• 1 msec corresponds to ( 8000/1000 * 1 ) = 8 samples • 2 msec corresponds to ( 8000/1000 * 2) = 16 samples

Now, Auto-correlation function (ACF) gives values of the correlation at different values of lag (τ). So if a signal of unknown frequency, is present its’ ACF plot looks like Figure below,

Figure 6: Auto Correlation Function of Input Signal

This process of guessing the unknown time-period / frequency by using the signal’s ACF is exactly what is done using the DSP.

Page 9: Application specific Programming of the Texas Instruments  ...

9 Application specific Programming of the Texas Instruments TMS320C6711 using Simulink

Figure 7: Simulink Model

Note that the Sub-Matrix block is required to override the presence of a maxima at lag = 0. The maxima within the range of 8 to 16 samples is what is of interest.

By the above process, the value of the unknown frequency is calculated. The value remains calculated and sits pretty within the DSP. However, as the DSP does not have a monitor/output screen, there is no way of accessing the calculated value! RTDX or Real Time Data Exchange can be used to access this value.

Troubleshooting the DSK1. Connect the power and observe the Power On Self-Test (POST). If the POST sequence

(as given in a previous section ) is OK it means that the DSK is working properly.2. Check the Parallel Port cable from the DSK to Computer. A loose cable can cause the

DSK to not be detected correctly.3. If working on Older Computers remember to set your parallel port to SPP or EPP. Failure

to do this will cause the DSK not to be detected.4. If the while running the Code CCS hangs, be patient and wait for an error message to

appear. Do not attempt to forcibly close CCS as if CCS is forcibly closed the board will not run unless the Computer is restarted.

5. If you get memory Map errors reset the DSK (through CCS) and try again. If this fails turn the power to the DSK off and then on (This may cause CCS to hang for a while).

6. Always remember to close CCS before switching off the DSK.7. Similarly the DSK should be switched on first and then the code should be generated

from Simulink (CCS will open automatically during the process).