Skip to content Skip to navigation

Connexions

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

Navigation

Recently Viewed

This feature requires Javascript to be enabled.
Download
x

Download module as:

  • PDF
  • EPUB (what's this?)

    What is an EPUB file?

    EPUB is an electronic book format that can be read on a variety of mobile devices.

    Downloading to a reading device

    For detailed instructions on how to download this content's EPUB to your specific device, click the "(what's this?)" link.

  • More downloads ...
Reuse / Edit
x

Module:

Add to a lens
x

Add module to:

Add to Favorites
x

Add module to:

 

Code Composer Studio Tutorial

Module by: Deania Fernandez. E-mail the author

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.

Figure 1
Figure 1 (SelectingCodeComposer.jpg)

You should see the following screen:

Figure 2
Figure 2 (CodeComposerWorkEnvironment.jpg)

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:

Figure 3
Figure 3 (CreatingANewFile.jpg)

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:

Figure 4
Figure 4 (SavingAFilePrompt.jpg)

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:

Figure 5
Figure 5 (ProjectCreationDialog.jpg)

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:

Figure 6
(a) Before expanding project(b) After expanding project
Figure 6(a) (BeforeExpandingProject.jpg)Figure 6(b) (AfterExpandingProject.jpg)

Adding New Files to the Project

In order to add new files, select Project --> Add Files to Project… The following prompt will appear:

Figure 7
Figure 7 (AddingFilesPrompt.jpg)

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:

Figure 8
Figure 8 (ExpandingSource.jpg)

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:

Figure 9
Figure 9 (AfterCompilingWindow.jpg)

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:

Figure 10
Figure 10 (LoadProgramPrompt.jpg)

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:

Figure 11
Figure 11 (SelectingOutFilePrompt.jpg)

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:

Figure 12
Figure 12 (SelectingDebugRun.jpg)

Your program will then begin to run. You will see the following at the bottom left-hand corner of the Code Composer Studio environment:

Figure 13
Figure 13 (CPURunning.jpg)

To stop running your code, select Debug --> Halt:

Figure 14
Figure 14 (SelectingHaltCPU.jpg)

You should then see the following at the bottom left-hand corner of the work environment:

Figure 15
Figure 15 (CPUHalted.jpg)

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:

Figure 16
Figure 16 (SettingBreakpoint.jpg)

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:

Figure 17
Figure 17 (RemovingBreakpoint.jpg)

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:

Figure 18
Figure 18 (WatchWindows.jpg)

Click on the ‘Watch 1’ tab:

Figure 19
Figure 19 (ClickOnWatchWindow.jpg)

To add a variable, double-click on the row under the ‘Name’ column:

Figure 20
Figure 20 (SettingAWatchVariable.jpg)

Type in the name of the variable and press the Enter key:

Figure 21
Figure 21 (EnteringAWatchVariable.jpg)

You can change the base of the value by clicking on the ‘Radix’ column and selecting how you want to view the value.

Figure 22
Figure 22 (ChangingBaseInWatchWindow.jpg)

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:

Figure 23
Figure 23 (ProfileSesionNameDialog.jpg)

Type in a name for your profile session and click OK.

A window will appear at the bottom:

Figure 24
Figure 24 (ProfileWindow.jpg)

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:

Figure 25
Figure 25 (SelectingViewClock.jpg)

The following window should appear at the bottom:

Figure 26
Figure 26 (ClockWindow.jpg)

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.

Content actions

Download module as:

PDF | EPUB (?)

What is an EPUB file?

EPUB is an electronic book format that can be read on a variety of mobile devices.

Downloading to a reading device

For detailed instructions on how to download this content's EPUB to your specific device, click the "(?)" link.

| More downloads ...

Add module to:

My Favorites (?)

'My Favorites' is a special kind of lens which you can use to bookmark modules and collections. 'My Favorites' can only be seen by you, and collections saved in 'My Favorites' can remember the last module you were on. You need an account to use 'My Favorites'.

| A lens I own (?)

Definition of a lens

Lenses

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

What is in a lens?

Lens makers point to 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 member, a community, or a respected organization.

What are tags? tag icon

Tags are descriptors added by lens makers to help label content, attaching a vocabulary that is meaningful in the context of the lens.

| External bookmarks

Reuse / Edit:

Reuse or edit module (?)

Check out and edit

If you have permission to edit this content, using the "Reuse / Edit" action will allow you to check the content out into your Personal Workspace or a shared Workgroup and then make your edits.

Derive a copy

If you don't have permission to edit the content, you can still use "Reuse / Edit" to adapt the content by creating a derived copy of it and then editing and publishing the copy.