Program Development Tools: Code Composer Studio IDE
Program Development Tools: Code Composer Studio IDE
Introduction
The objective of this module is to understand the basic functions of the Code Composer Studio
Integrated Design Environment for the C2000 - Family of Texas Instruments Digital Signal
Processors. This involves understanding the basic structure of a project in C and Assembler -
coded source files, along with the basic operation of the C-Compiler, Assembler and Linker
Productive Editor:
¾Structure Expansion Status Watch window Graph
window Memory window
window
2-2
Module Topics
Introduction .............................................................................................................................................2-1
Code Composer Studio IDE.....................................................................................................................2-1
Module Topics..........................................................................................................................................2-2
The Software Flow ...................................................................................................................................2-3
Code Composer Studio - Basics...............................................................................................................2-4
Lab Hardware Setup ................................................................................................................................2-7
Code Composer Studio – Step by Step .....................................................................................................2-9
Create a project..................................................................................................................................2-10
Setup Build Options...........................................................................................................................2-12
Linker Command File........................................................................................................................2-13
Download code into DSP ..................................................................................................................2-15
Lab 1: beginner’s project.......................................................................................................................2-23
Objective ...........................................................................................................................................2-23
Procedure...........................................................................................................................................2-23
Open Files, Create Project File..........................................................................................................2-23
Build SIM
Compile lnk.cmd Probe In
eZdsp™
eZdsp™
Asm Link Debug
EVM
DSP/BIOS
DSP/BIOS Probe Out
Edit Config Third
Libraries Graphs
Tool Party
Profiling
XDS
Code Composer Studio includes:
Integrated Edit/Debug GUI DSP
Code Generation Tools Board
DSP/BIOS
2-3
You can use Code Composer Studio with a Simulator (running on the Host – PC) or you can
connect a real DSP system and test the software on a real “target”. For this tutorial, we will rely
on the eZdsp (TMS320F2812eZdsp – Spectrum Digital Inc.) as our “target” and some additional
hardware. Here the word “target” means the physical processor we are using, in this case a DSP.
The next slides will show you some basic features of Code Composer Studio and the hardware
setup for lab exercises that follow.
Integrates:
Integrates: edit, code generation,
and debug
Single-
Single-click access using buttons
Built-
Built-in access to BIOS functions
2-4
Project (.pjt
(.pjt)) files contain:
Source files (by reference)
Source (C, assembly)
Libraries
DSP/BIOS configuration
Linker command files
Project settings:
Build Options (compiler and
assembler)
Build configurations
DSP/BIOS
Linker
2-5
2-6
2-7
2-8
Parallel Port/
JTAG
Controller
Interface (P3)
25 pin male
D-sub connector
(Plugs into parallel
port on PC)
25 Conductor Cable
eZdsp F2812
25 pin male
D-sub connector
Power
Supply
To be able to practice with all the peripheral units of the DSP and some ‘real’ process hardware,
we’ve added an adapter board, which fits underneath the eZdspF2812. The Zwickau Adapter
Board provides:
• 8 switches (GPIO B15…B8) and 2 push buttons (GPIO D1, D6) for digital input
8 x switch
8 x LED
1 CAN - Transceiver ( TJA 1054 )
1 Loudspeaker
2 x push- button
2 potentiometers 1 SCI - Transceiver (MAX 232)
Project-
tree
Working
Area
2 - 13
The step-by-step approach for Lab1 will show how to do the following:
• Watch Variables
Before we start to go into the procedure for Lab1, let’s discuss the steps using some additional
slides:
Create a project
• Project Î New
give your project a name : “Lab1”, select a target and a suitable
location of your hard disk:
Note : the project file (“Lab1.pjt) is a simple text file (ASCII) and stores
all set-ups and options of the project. This is very useful for a version
management.
2 - 14
The first task is to create a project. This is quite similar to most of today’s design environments
with one exception: we have to define the correct target, in our case “TMS320C28xx”. The
project itself generates a subdirectory with the same name as the project. Ask your instructor for
the correct location to store your project.
unsigned int k;
void main (void)
{
unsigned int i;
while(1)
{
for (i=0;i<100;i++)
k=i*i;
}
}
Next, write the source code for your first application. The program from the slide above is one of
the simplest tasks for a processor. It consists of an endless loop, which counts variable i from 0 to
99, calculates the current product of i * i and stores it temporarily in k. It seems to be an affront to
bother a sophisticated Digital Signal Processor with such a simple task! Anyway, we want to gain
hands-on experience of this DSP and the simple the program is an easy way for us to evaluate the
basic commands of the.
2 - 16
Your source code file is now stored on the PC’s hard disk but it is not yet part of the project. Why
does Code Composer Studio not add this file to our project automatically? Answer: If this were
an automatic procedure, then all the files that we touch during the design phase of the project
would be added to the project, whether we wanted or not. Imagine you open another code file,
just to look for a portion of code that you used in the past; this file would become part of your
project.
To add a file to your project, you will have to use an explicit procedure. This is not only valid for
source code files, but also for all other files that we will need to generate the DSP’s machine
code. The following slide explains the next steps for the lab exercise:
When you’ve done everything correctly, the build options window should look like this:
2 - 19
Memory
0x00 0000
Sections
M0SARAM
(0x400)
.ebss
0x00 0400 M1SARAM
(0x400)
.stack
.text
2 - 20
Linking
zz Memory
Memorydescription
description
zz How
How to places/w
to place s/winto
intoh/w
h/w
name.cmd
.map
2 - 21
The procedure of linking connects one or more object files (*.obj) into an output file (*.out). This
output file contains not only the absolute machine code for the DSP, but also information used to
debug, to flash the DSP and for more JTAG based tasks. Do NEVER take the length of this
output file as the length of your code! To extract the usage of resources we always use the MAP
file (*.map).
MEMORY
{
PAGE 0: /* Program Space */
FLASH: org = 0x3D8000, len = 0x20000
PAGE 1: /* Data Space */
M0SARAM: org = 0x000000, len = 0x400
M1SARAM: org = 0x000400, len = 0x400
}
SECTIONS
{
.text: > FLASH PAGE 0
.ebss:
ebss: > M0SARAM PAGE 1
.cinit:
cinit: > FLASH PAGE 0
.stack: > M1SARAM PAGE 1
}
2 - 22
2 - 23
After Î Debug Î Go main, a yellow arrow shows the current position of the Program Counter
(PC). This register points always the next instruction to be executed.
yellow arrow :
current PC
2 - 24
When we start to test our first program, there is no hardware activity to be seen. Why not? Well,
our first program does not use any peripheral units of the DSP. Go through the steps, shown on
the next slide.
To watch the program’s variables, we can use a dedicated window called the “Watch Window”.
This is probably the most used window during the test phase of a software project.
2 - 26
Watch-
Window
2 - 27
Another useful part of a debug session is the ability to debug the code in portions and to run the
program for a few instructions. This can be done using a group of singe-step commands:
2 - 28
Step Out
2 - 29
When you’d like to run the code through a portion of your program that you have tested before, a
Breakpoint is very useful. After the ‘run’ command, the JTAG debugger stops automatically
when it hits a line that is marked with a breakpoint.
6. Add a breakpoint
Set a breakpoint:
Place the Cursor in Lab1.c on line : k = i * i;
Click right mouse and select ‘Toggle Breakpoint’
the line is marked with a red dot ( = active breakpoint )
Note : most Code Composer Studio Commands are also available through
buttons or trough Command -Keys ( see manual, or help )
Reset the Program:
Î Debug Î Reset CPU
Î Debug Î Restart
Perform a real time run:
Î Debug Î Run (or F5)
DSP stops when reaching an active breakpoint
repeat ‘Run’ and watch your variables
remove the breakpoint ( Toggle again) when you’re done.
2 - 30
Remove all
Breakpoints
2 - 31
A slightly different tool to stop the execution is a ‘Probe Point’. While the Break Point forces the
DSP to halt permanently, the Probe Point is only a temporary stop point. During the stop status,
the DSP and the JTAG-emulator exchange information. At the end, the DSP resumes the
execution of the code.
NOTE: There is a more advanced method to interact with the DSP in real time, called ‘Real Time
Debug’. We will skip this option for the time being and use this feature during later chapters.
2 - 33
When you are more familiar with the F2812 and with the tools, you might want to verify the
efficiency of the C compiler or to optimize your code at the Assembler Language level.
2 - 34
Current
C - line
Current
Instruction
2 - 35
The General Extension Language (GEL) is a high-level script language. Based on a *.gel – file
one can expand the features of Code Composer Studio or perform recurrent steps automatically.
Objective
The objective of this lab is to practice and verify the basics of the Code Composer
Studio Integrated Design Environment.
Procedure
unsigned int k;
void main (void)
{
unsigned int i;
while(1)
{
for (i = 0; i < 100; i++)
k = i * i;
}
}
Save this file by clicking File Æ Save as and type in: Lab1.c
4. Add the C-runtime library to your project by clicking: Project Æ Build Op-
tions Æ Linker Æ Library Search Path: ‘c:\ti\c2000\cgtools\lib’. Then Add
the library by clicking: Project Æ Build Options Æ Linker Æ Include Librar-
ies: ‘rts2800_ml.lib’
6. Set the stack size to 0x400: Project Æ Build Options Æ Linker Æ Stack Size
8. Click the “Rebuild All” button or perform: Project Æ Build and watch the
tools run in the build window. Debug as necessary. To open up more space,
close any open files or windows that you do not need at this time.
9. Load the output file onto the eZdsp. Click: File Æ Load Program and choose
the output file you generated. Note: The binary output file has the same name
as the project with the extension .out. The file is stored under the “Debug”
subfolder.
Note: Code Composer can automatically load the output file after a successful
build. To do this by default, click on the menu bar: Option Æ Customize Æ
Program Load Options and select: “Load Program After Build”, then click
OK.
Test
10. Reset the DSP by clicking on Æ Debug Æ Reset CPU, followed by Æ Debug
Æ Restart
11. Run the program until the first line of your C-code by clicking: Debug Æ Go
main. Verify that in the working area the source code “Lab1.c” is highlighted
and that the yellow arrow for the current Program Counter is placed on the
line ‘void main (void)’.
13. Verify the note at the bottom left corner of the screen: “DSP Running” to
mark a real time run. Because we are doing nothing with peripherals so far,
there is no other visible activity.
14. Halt the program by clicking: Debug Æ Halt, reset the DSP (Debug Æ Reset
CPU, followed by Æ Debug Æ Restart) and go again until main (Debug Æ
Go main)
15. Open the Watch Window to watch your variables. Click: View Æ Watch
Window. Look into the window “Watch locals”. Once you are in main, you
should see variable i. Variable k is a global one. To see this variable we have
to add it to the window ‘Watch 1’. Just enter the name of variable ‘k’ into the
first column ‘Name’. Use line 2 to enter variable i as well. Exercise also with
the ‘Radix’ column.
16. Perform a single-step through your program by clicking: Debug Æ Step Into
(or use function Key F8). Repeat F8 and watch your variables.
17. Place a Breakpoint in the Lab1.c – window at line “k = i * i;”. Do this by plac-
ing the cursor on this line, click right mouse and select: “Toggle Breakpoint”.
The line is marked with a red dot to show an active breakpoint. Perform a real-
time run by Debug Æ Run (or F5). The program will stop execution when it
reaches the active breakpoint. Remove the breakpoint after this step (click
right mouse and “Toggle Breakpoint”).
18. Set a Probe Point. Click right mouse on the line “k=i*i;”. Select “Toggle
Probe Point”. A blue dot in front of the line indicates an active Probe-Point.
From the menu-bar select “Debug Æ Probe Points...”. In the dialog window,
click on the line “Lab1.c line 13 Æ No Connection”. Change the “connect to”-
selector to “Watch Window”, click on ‘Replace’ and ‘OK’. Run the program
again (F5). You will see that the probe point updates the watch window each
time the program passes the probe point.
19. Have a look into the DSP-Registers: View Æ Registers Æ CPU Register and
View Æ Registers Æ Status Register. Right mouse click inside these windows
and select “Float in Main Window”. Double click on the line ACC in the
CPU-Register and select ‘Edit Register’. Modify the value inside the Accumu-
lator.
20. You might want to use the workspace environment in further sessions. For this
purpose, it is useful to store the current workspace. To do so, click: File Æ
Workspace Æ Save Workspace and save it as “Lab1.wks”
21. Delete the active probe by clicking on the button “Remove all Probe Points”,
close the project by Clicking Project Æ Close Project and close all open win-
dows that you do not need any further.