Connexions

You are here: Home » Content » Code Composer Studio Tutorial
Content Actions
Lenses

What is a lens?

Lenses

A lens is a custom view of Connexions content. You can think of it as a fancy kind of list that will let you see Connexions through the eyes of organizations and people you trust.

What is in a lens?

Lens makers point to Connexions materials (modules and collections), creating a guide that includes their own comments and descriptive tags about the content.

Who can create a lens?

Any individual Connexions member, a community, or a respected organization.

This content is ...
Affiliated with (?)
This content is either by members of the organizations listed or about topics related to the organizations listed. Click each link to see a list of all content affiliated with the organization.
  • This module is included inLens: Rice University OpenCourseWare
    By: OpenCourseWare ConsortiumAs a part of collection:"High-Speed and Embedded Systems Design (Under Construction)"

    Click the "Rice University OCW" link to see all content affiliated with them.

    Rice University OCW
Tags

(?)

These tags come from the endorsement, affiliation, and other lenses that include this content.

Code Composer Studio Tutorial

Module by: Deania Fernandez

Summary: A brief tutorial on how to get started using Code Composer Studio.

Introduction

This is a brief tutorial over Code Composer Studio which is a programming environment used to implement various algorithms and load code onto a DSP. If you would like a more in-depth tutorial, please feel free to click on Help -->Tutorial in Code Composer.

Starting Code Composer Studio

Before starting, it would be a good idea to create a folder where you will be saving your project files. Label the folder ELEC424_Tutorial.
To open Code Composer Studio in a Windows 2000 system, click on Start and select Programs --> Texas Instruments --> Code Composer Studio DSK Tools 2 (‘C2000) --> Code Composer Studio.
SelectingCodeComposer.jpg
Figure 1
You should see the following screen:
CodeComposerWorkEnvironment.jpg
Figure 2

Creating a File

To create a new source code file, click on File --> Source File. A window titled ‘Untitled1’ will appear within the Composer environment:
CreatingANewFile.jpg
Figure 3
You can double-click on the ‘Untitled1’ window to make it larger.
To save your file, click on File --> Save. The following prompt will appear:
SavingAFilePrompt.jpg
Figure 4
There are several Save as type… options. Choose the appropriate one for your code. It will give your file the proper file extension. It is also lets the linker know when you compile your code what kind of language the file is written in.
When you are done, click Save.

Creating a New Project

After you have finished creating the files you need to run on the DSP, you will now want to create a project that will include all the files. Select Project --> New…
The following prompt will appear:
ProjectCreationDialog.jpg
Figure 5
Fill in the project name in Project Name. Browse to the folder you created for the project in Location. Make sure you select Executable (.out) in Project Type, and select TMS320C28XX in Target. When you are done, click Finish.
Example.pjt will appear in the left-hand side of the Composer environment. Click on the ‘+’ to expand the project:
BeforeExpandingProject.jpgAfterExpandingProject.jpg
Subfigure 6.1: Before expanding project
Subfigure 6.2: After expanding project
Figure 6

Adding New Files to the Project

In order to add new files, select Project --> Add Files to Project… The following prompt will appear:
AddingFilesPrompt.jpg
Figure 7
Select the file you want to add. To make it easier, you can narrow your search of a particular file by choosing which type of file you want in the Files of type…
When you are done, click Open.
You should now see the file after clicking on the ‘+’ in the left-hand window:
ExpandingSource.jpg
Figure 8

Compiling Files and Building Projects

Once you have added all the files you want to be included in your project, you will now need to build your project. Select Project --> Rebuild All. You should see the following window at the bottom of the Code Composer Studio Environment:
AfterCompilingWindow.jpg
Figure 9
If there are errors in your code, they will be listed with the corresponding line numbers. Correct them and rebuild your project.

Loading/Reloading Programs

After your code has been successfully compiled and built, you must now load your program onto the DSP. Select File --> Load Program… You will see the following prompt dialog:
LoadProgramPrompt.jpg
Figure 10
When you rebuild your project, Code Composer Studio is set at default to create a new folder in your directory called Debug. This is where the executable file is created. Double-click on the Debug folder and you should see your *.out file:
SelectingOutFilePrompt.jpg
Figure 11
After you select your file, click Open.

Executing, Halting, or Stopping Your Program

To execute your program, select Debug --> Run or press the F5 key:
SelectingDebugRun.jpg
Figure 12
Your program will then begin to run. You will see the following at the bottom left-hand corner of the Code Composer Studio environment:
CPURunning.jpg
Figure 13
To stop running your code, select Debug --> Halt:
SelectingHaltCPU.jpg
Figure 14
You should then see the following at the bottom left-hand corner of the work environment:
CPUHalted.jpg
Figure 15
To resume running your code, press the F5 button.

Debugging Your Code

Since there are few of us that can get our code working right the first time, you will probably have to debug your code. To figure out what could be wrong, there are several methods you can use to break the problem down.

Setting Breakpoints

To execute your code a little at a time or to stop it after a certain point, you can place breakpoints. You can do this by placing the cursor on the line you want to set the breakpoint on, highlighting it by clicking once, and double-click. You should see a solid red circle on the left:
SettingBreakpoint.jpg
Figure 16
You can set as many as you like. Rebuild and reload the program. Execute it. The DSP will stop at the first breakpoint. To get to the next breakpoint, press the F5 button to run the DSP again.
To remove the breakpoint(s), place the cursor on the line, highlight it by clicking once, and double-click. The solid red circle should disappear:
RemovingBreakpoint.jpg
Figure 17

Watching Variables

To see what values your variables, constants, and/or registers are getting, you can view them in a watch window. Select View --> Watch Window. You should see the following appear in the Code Composer Studio environment:
WatchWindows.jpg
Figure 18
Click on the ‘Watch 1’ tab:
ClickOnWatchWindow.jpg
Figure 19
To add a variable, double-click on the row under the ‘Name’ column:
SettingAWatchVariable.jpg
Figure 20
Type in the name of the variable and press the Enter key:
EnteringAWatchVariable.jpg
Figure 21
You can change the base of the value by clicking on the ‘Radix’ column and selecting how you want to view the value.
ChangingBaseInWatchWindow.jpg
Figure 22

Profiling Sessions

You can benchmark your code by profiling a session. To do this, you can set one breakpoint at the line where you want the counter to start counting and another breakpoint at where to stop.
Select Profiler --> Start New Session… You will see the following dialog:
ProfileSesionNameDialog.jpg
Figure 23
Type in a name for your profile session and click OK.
A window will appear at the bottom:
ProfileWindow.jpg
Figure 24
To profile a function, you need to add it to the profile session you just created. Double-click on the file you want to do this in, and place the cursor on any line inside the function and right click. Choose Profile Function --> in (session-name) Session.
Execute the code. When the CPU stops, click on the ‘Functions’ tab to see the result of the profiling.

Counting Clock Cycles

If you just want to count the cycles and do not need all the stats from profiling, you can just view the clock. SelectProfiler --> View Clock:
SelectingViewClock.jpg
Figure 25
The following window should appear at the bottom:
ClockWindow.jpg
Figure 26
After setting up your breakpoints, reset the PC to start at the beginning of your code by selecting Debug --> Reset. Run your code. Clear the clock by double-clicking on it, and then run it again. The number of clock cycles will appear in the clock window.

Troubleshooting

If you are having any trouble, sometimes it is best to reset the CPU. You can do this by selecting Debug --> Restart CPU. You will have to reload the program.
Another option is to simply quit Code Composer Studio by selecting File --> Quit and restart the application.

Comments, questions, feedback, criticisms?

Send feedback