AIR UNIVERSITY
DEPARTMENT OF ELECTRICAL AND COMPUTER ENGINEERING
EXPERIMENT NO 4
Lab Title: INTRODUCTION TO CODE COMPOSER STUDIO, DEBUGGING USING
BREAKPOINTS AND WATCH WINDOW
Student Name: Yehia Maged Reg. No: 222692 _
Objective: To gain hands-on familiarity with Code Composer Studio (CCS), configuring, and
building the projects to visualize outputs, and use of breakpoints and watch window.
LAB ASSESSMENT:
Excellent Good Average Satisfactory Unsatisfactory
Attributes
(5) (4) (3) (2) (1)
Ability to Conduct
Experiment
Ability to assimilate the
results
Effective use of lab
equipment and follows
the lab safety rules
Total Marks: Obtained Marks: _
LAB REPORT ASSESSMENT:
Excellent Good Average Satisfactory Unsatisfactory
Attributes
(5) (4) (3) (2) (1)
Data presentation
Experimental results
Conclusion
Total Marks: Obtained Marks: _
Date: Signature: _
LABORATORY
EXPERIMENT
NO. 04
INTRODUCTION TO CODE
COMPOSER STUDIO, DEBUGGING
USING BREAKPOINTS AND
WATCH WINDOW
Objectives:
• Introducing students to Code Composer Studio (CCS)
• Creating new projects in CCS, configuring, and building the projects to visualize outputs
• Familiarizing students with breakpoints and watch window
Equipment required:
• Code Composer Studio v5.41
Background Knowledge:
Code Composer Studio (CCS) is Texas Instruments’ integrated development environment (IDE) for
developing routines on a wide variety of their Digital Signal Processors (DSPs). In CCS, the editing,
code generation, and debugging tools are all integrated into one unified environment. Users can
select target DSP, adjust optimization parameters, and set user preferences. It has graphical
capabilities and supports real-time debugging. It provides an easy-to-use software tool to build and
debug programs.
Definitions:
Some of the definitions that will be frequently used in the lab are given below:
TMS320C6713 or DSK6713:
A DSP development board containing chips from Texas Instruments. The TMS320C6713 DSP Starter
Kit (DSK) developed jointly with Spectrum Digital is a low-cost development platform designed to
speed the development of high precision applications. The kit uses USB communications for true
plug-and-play functionality. The chip is optimized to perform functions extensively used in DSP
programs.
AIC23:
The Codec (Coder/Decoder) chip on the DSK. The AIC23 codec performs both the analog-to-digital
conversion (ADC) and digital-to-analog conversion (DAC) functions.
Workspace:
A CCS directory which contains one or (typically) multiple projects. Workspaces can only be created
by CCS, which will add hidden files containing CCS settings and information. There is essentially no
limit to the number of workspaces that can be created.
2|Page
Project:
A directory within a CCS workspace containing a collection of files, including user’s code which can
be compiled and run on the DSK. A project can have only one file with a main() function, which is the
starting point for any c program.
Chip Support Library:
The Chip Support Library (CSL) provides an application programming interface (API) used for
configuring and controlling the DSP on-chip peripherals for ease of use, compatibility between
various C6000 devices and hardware abstraction. For the C6713, the chip support library, supplied
by Texas Instruments, is installed under C:/program files/C6xCSL/.
Board Support Library:
A board support library (BSL) is essential code for a given computer hardware device, which provides
low-level board functions such as USB-to-JTAG translation, read-write access to control registers, etc.
For the DSK, the board support library, supplied by the manufacturer Spectrum Digital, Inc, is
installed under C:/program files/C6xCSL/.
Installing CCS:
To install CCS on your PCs, download the installation file from Texas Instrument’s website and run
the installer. The CCS version 5 installer gives a warning message when being installed on Windows
10. Click Yes, ignoring the message.
Follow the given steps to properly install CCS on your PC.
3|Page
After accepting the license agreement, select the installation folder directory.
Select custom as the setup type.
4|Page
Select the processor architectures and click next. Select all default components and click on next.
5|Page
Select Spectrum Digital Emulator and click next.
6|Page
Once the installation is complete, a dialog box will appear which is known as a Workspace launcher.
All your project folders are stored in your workspace. You can either choose to work in the default
workspace or create one in your desired directory.
After creating your workspace, a window opens which allows you to explore CCS resources.
7|Page
To create a new CCS project, go to file, new, CCS project. A dialog box will appear. Fill in the blank
fields as shown in the given figure:
Click on Finish button and a new window will appear which shows the “Edit Perspective” in the CCS
GUI, which is used to write and compile programs. The Project Explorer pane, shown on the left, is
used to access projects within a single workspace. This contains Project Explorer tab.
8|Page
The Edit Perspective for an example project is given below:
The figure given below shows the “Debug Perspective” in the CCS GUI. In this environment, the
program has been downloaded to the board and can be run, halted, and run to breakpoints.
9|Page
Introduction to C Language:
In CCS, c language is going to be used as coding language. In this section, we revise the basic concepts
of c language. A C program basically consists of the following parts:
• Pre-processor Commands
• Functions
• Variables
• Statements & Expressions
• Comments
The following code prints Hello, World! on console.
#include "stdio.h"
void main()
{
/* my first program in C */
printf("Hello, World! \n");
}
• The first line of the program #include <stdio.h> is a pre-processor command, which tells a
C compiler to include stdio.h file before starting program compilation.
• The next line void main() is the main function where program execution begins.
• The next line /*...*/ will be ignored by the compiler and it has been put to add additional
comments in the program.
• The next line printf(...) is another function available in C which causes the message "Hello,
World!" to be displayed on console.
• In C program, the semicolon is a statement terminator. Each statement must be ended with a
semicolon.
Identifiers:
A C identifier is a name used to identify a variable, function, or any other user-defined item. An
identifier starts with a letter A to Z or a to z or an underscore _ followed by zero or more letters,
underscores, and digits (0 to 9). C does not allow punctuation characters such as @, $, and % within
identifiers. C is a case sensitive programming language.
Keywords:
The following list shows the reserved words in C. These reserved words may not be used as constant
or variable or any other identifier names.
10 | P a g e
Data Types:
In C programming language, data types refer to an extensive system used for declaring variables or
functions of different types. The type of a variable determines how much space it occupies in storage
and how the bit pattern stored is interpreted. The various data types include int, float, void etc.
Variables:
A variable is a name given to a storage area which can be addressed and modified in the code. Each
variable in C has a specific type, which determines the size of the variable's memory; the range of
values that can be stored within that memory; and the set of operations that can be applied to the
variable. Following are the basic variable types:
Constants and Literals:
Certain characters in C are preceded by a backslash and have special functions such as newline (\n)
or tab (\t). String literals or constants are enclosed in double quotes "". A string contains characters
that are similar to character literals: plain characters, escape sequences, and universal characters.
Operators:
An operator is a symbol that tells the compiler to perform specific mathematical or logical
manipulations. C language is rich in built-in operators and provides the following types of operators:
• Arithmetic Operators
• Relational Operators
• Logical Operators
• Bitwise Operators
• Assignment Operators
11 | P a g e
Arithmetic Operators:
The following example explains the working of arithmetic operators:
#include <stdio.h>
main()
{
int a = 21;
int b = 10;
int c ;
c = a + b;
printf("Line 1 - Value of c is %d\n", c );
c = a - b;
printf("Line 2 - Value of c is %d\n", c );
c = a * b;
printf("Line 3 - Value of c is %d\n", c );
c = a / b;
printf("Line 4 - Value of c is %d\n", c );
c = a % b;
printf("Line 5 - Value of c is %d\n", c );
c = a ++;
printf("Line 6 - Value of c is %d\n", c );
c = a --;
printf("Line 7 - Value of c is %d\n", c );
}
Output:
Line 1 - Value of c is 31
Line 2 - Value of c is 11
Line 3 - Value of c is 210
Line 4 - Value of c is 2
Line 5 - Value of c is 1
Line 6 - Value of c is 21
Line 7 - Value of c is 22
Relational Operators:
The following example explains the working of relational operators:
#include <stdio.h>
main()
{
int a = 21;
int b = 10;
int c ;
if( a == b )
{
printf("Line 1 - a is equal to b\n" );
}
else
{
printf("Line 1 - a is not equal to b\n" );
}
if ( a < b )
{
12 | P a g e
printf("Line 2 - a is less than b\n" );
}
else
{
printf("Line 2 - a is not less than b\n" );
}
if ( a > b )
{
printf("Line 3 - a is greater than b\n" );
}
else
{
printf("Line 3 - a is not greater than b\n" );
}
/* Lets change value of a and b */
a = 5;
b = 20;
if ( a <= b )
{
printf("Line 4 - a is either less than or equal to b\n" );
}
if ( b >= a )
{
printf("Line 5 - b is either greater than or equal to b\n" );
}
}
Output:
Line 1 - a is not equal to b
Line 2 - a is not less than b
Line 3 - a is greater than b
Line 4 - a is either less than or equal to b
Line 5 - b is either greater than or equal to b
The codes for logical, bitwise, and other operator types can be written in the same way.
Decision Making:
Decision making structures require that the programmer specify one or more conditions to be
evaluated or tested by the program, along with a statement or statements to be executed if the
condition is determined to be true, and optionally, other statements to be executed if the condition is
determined to be false.
if statement:
An if statement consists of a Boolean expression followed by one or more statements. The syntax of
an if statement in C programming language is:
if(boolean_expression)
{
/* statement(s) will execute if the boolean expression is true */
}
If the Boolean expression evaluates to true, then block of code inside if statement will be executed.
13 | P a g e
If Boolean expression evaluates to false, then the first set of code after the end of the if statement
(after the closing curly brace) will be executed.
For example:
#include <stdio.h>
int main ()
{
/* local variable definition */
int a = 10;
/* check the boolean condition using if statement */
if( a < 20 )
{
/* if condition is true then print the following */
printf("a is less than 20\n" );
}
printf("value of a is : %d\n", a);
return 0;
}
Output:
a is less than 20
value of a is : 10
if-else Statements:
An if statement can be followed by an optional else statement, which executes when the Boolean
expression is false. The syntax of an if...else statement in C programming language is:
if(boolean_expression)
{
/* statement(s) will execute if the boolean expression is true */
}
else
{
/* statement(s) will execute if the boolean expression is false */
If the Boolean expression evaluates to true, then the if block of code will be executed, otherwise else
block of code will be executed.
For example:
#include <stdio.h>
int main ()
{
/* local variable definition */
int a = 100;
/* check the boolean condition */
if( a < 20 )
{
/* if condition is true then print the following */
printf("a is less than 20\n" );
14 | P a g e
}
else
{
/* if condition is false then print the following */
printf("a is not less than 20\n" );
}
printf("value of a is : %d\n", a);
return 0;
}
Output:
a is not less than 20
value of a is : 100
Similarly, if statement can be followed by an optional else if...else statement, which is useful to test
various conditions. Nested if statements are also frequently used in C programming.
Loops:
A loop is used when a block of code needs to be executed several number of times. In general,
statements are executed sequentially: The first statement in a function is executed first, followed by
the second, and so on. Programming languages provide various control structures that allow for more
complicated execution paths.
while Loop:
A while loop statement in C programming language repeatedly executes a target statement as long as
a given condition is true. The syntax of a while loop in C programming language is:
while(condition)
{
statement(s);
}
Here, statement(s) may be a single statement or a block of statements. The loop iterates while the
condition is true. When the condition becomes false, program control passes to the line immediately
following the loop.
For example:
#include <stdio.h>
int main ()
{
/* local variable definition */
int a = 10;
/* while loop execution */
while( a < 20 )
{
printf("value of a: %d\n", a);
a++;
}
return 0;
}
15 | P a g e
Output:
value of a: 10
value of a: 11
value of a: 12
value of a: 13
value of a: 14
value of a: 15
value of a: 16
value of a: 17
value of a: 18
value of a: 19
for Loop:
A for loop is a repetition control structure that allows you to efficiently write a loop that needs to
execute a specific number of times. The syntax of a for loop in C programming language is:
for ( init; condition; increment )
{
statement(s);
The flow of control in a for loop is:
1. The init step is executed first, and only once. This step allows the user to declare and initialize
any loop control variables.
2. Next, the condition is evaluated. If it is true, the body of the loop is executed. If it is false, the
body of the loop does not execute, and flow of control jumps to the next statement just after
the for loop.
3. After the body of the for loop executes, the flow of control jumps back up to the increment
statement. This statement allows user to update any loop control variables. This statement
can be left blank, as long as a semicolon appears after the condition.
4. The condition is now evaluated again. If it is true, the loop executes and the process repeats
itself (body of loop, then increment step, and then again condition). After the condition
becomes false, the for loop terminates.
For example:
#include <stdio.h>
int main ()
{
int a;
/* for loop execution */
for(a =10; a<20; a =a+1)
{
printf("value of a: %d\n", a);
}
return 0;
}
16 | P a g e
Output:
value of a: 10
value of a: 11
value of a: 12
value of a: 13
value of a: 14
value of a: 15
value of a: 16
value of a: 17
value of a: 18
value of a: 19
Similarly, do while is used to repeat a certain block of code while a condition is true. Nested loops are
also frequently used in various codes.
Example Project:
In the following example, a simple CCS project is created (by following the above-mentioned steps)
which displays a string when the program is debugged. Type the following code in main.c file.
Code:
#include "stdio.h"
void main()
{
printf("Introduction to Code Composer Studio \n");
}
Building the Project:
To build the project, select Project from the main menu and click Build Project. CCS will now
compile and link the project files to produce an executable file. If all is well, the console window will
show “Build Finished”. Note that CCS has various menu buttons that have the same function as the
menu commands.
17 | P a g e
Project Debugging:
Go to Run button on main menu and click Debug. The following window appears along with the code
file and output console.
The program can be suspended and resumed as desired. Note that the key items from the target menu
are available as buttons in the debug window. The code can be modified and rebuilt even when the
hardware is running. However, to implement the changes, the program must be rebuilt and reloaded.
The example code given above generates the following result:
Breakpoints and Watch Window:
Breakpoints stop the execution of the program. When the program is stopped, user can examine the
state of program, examine, or modify variables, examine the call stack, etc. User can set a breakpoint,
by using the Toggle Breakpoint button on the Project toolbar or by selecting Debug->Breakpoints.
The latter brings up the Break/Probe/Profile Points dialog box. When a breakpoint is set, it can be
enabled or disabled.
In the following example, a breakpoint is added to watch the updating values of variable k.
#include "stdio.h"
void main()
{
int i;
int k;
for (i=0;i<=10;i++)
{
k=i*5;
printf(" %d \n" , k);
}
}
18 | P a g e
Run the program such that the debug window appears. Note that the pointer is at line 3.
Now go to the line where breakpoint should be placed. For instance, in the code given above, add a
breakpoint at k. Go to line k=i*5; and on the left side right click to add a breakpoint.
After a breakpoint is added, a window appears such that:
Run the program again and note that the pointer now moves to line where the breakpoint was added.
This means that the DSP has executed the code till this point.
Right click on the variable k and select Add Watch Expression option, name it k and press OK. A watch
window will appear, and the variable sum is added to it. For now, the value stored in this variable is
zero.
19 | P a g e
Run the program again. The sum in Watch window is updated, however, the yellow pointer is still
seen at the same location. This is because the breakpoint was placed in a loop and every time the loop
is executed, it encounters the breakpoint and stops.
Run the program for total iterations and see that the variable k in Watch Window is updated. The
output at the console is also updated after each run and the final output is:
0
5
10
15
20
25
30
35
40
45
50
Waveform Generation in CCS:
The Code Composer Studio can also be used to generate and visualize continuous and discrete time
waveforms. For example, to generate a sine wave in CCS, follow the given steps:
• Create a new CCS project and in main.c file, write the following code:
#include "stdio.h"
#include "math.h"
float i;
int j=0;
float a[100];
void main(void)
{
for(i=0;i<100;i=i+1)
{
a[j]=sin(2*3.14*0.01*i);
j++;
}
}
• Build the project, and if there are no errors displayed in the Problems window, proceed to
Debug perspective.
20 | P a g e
• Click on Tools Graph and choose Single Time. A dialog box like the one given below appears:
• The following fields are entered in the graph properties to get appropriate results:
− Acquisition Buffer Size is the size of array containing sample values.
− DSP data type is the type of DSP Kit being used to execute the program.
− The start address is set as the name of variable containing the amplitude values.
− Display Data Size should always be greater than or equal to the number of samples in
Acquisition Buffer.
• After setting these properties, an empty graph window appears alongside the console.
• Click on run button in the debug window and obtain the following plot in the graph
window:
• Right click on the plot. This displays various options to customize the plot.
• The Display Properties provide further customization options
21 | P a g e
Lab Tasks:
1. Write a code in CCS which takes an array input from user and outputs reverse of this array
on console.
Hint: if user entered x = 1 2 3 4 5 the output on console should be y = 5 4 3 2 1.
Code:
#include<stdio.h>
void main()
{
int n,i;
int a[50];
printf(" Enter size of array <=50 \n number= ");
scanf("%d",&n);
printf("\n Enter the array x= ");
for (i=1;i<=n;i++)
{
scanf("%d",&a[i]);
}
printf("\n reverse array y= ");
for (i=n;i>=1;i--)
{
printf(" %d ",a[i]);
}
}
Results:
22 | P a g e
2. Write a C program which takes the starting value and ending value of a range as input from
user using scanf command and calculate sum of values within this range. Display the results
on console.
Code:
#include <stdio.h>
int main()
{
int start, end;
int i;
int sum=0;
printf(" Enter the starting of the range: ");
scanf("%d", &start);
printf("\n Enter the ending of the range: ");
scanf("%d", &end);
for(i=start;i<=end;i++)
{
sum = sum + i;
}
printf("\n The sum of values from %d to %d is: %d\n", start, end, sum);
return 0;
}
Results:
23 | P a g e
3. Write a C Program to find largest element in an array and display the results on console.
Code:
#include <stdio.h>
int main()
{
int n,i;
int a[50];
int max=0;
printf(" Enter size of array <=50 : ");
scanf("%d", &n);
printf("\n Enter any elements for the array: ");
for (i=1;i<=n;i++)
{
scanf("%d", &a[i]);
}
for (i=1;i<=n;i++)
{
if (a[i]>max)
{
max=a[i];
}
}
printf("\n The largest element in the array: %d\n", max);
return 0;
}
Results:
24 | P a g e
4. Write a C Program which takes an integer input from user to generate a multiplication Table
and display the results on console. Add a breakpoint at loop location, and display results on
watch window as well.
Code (without breakpoint):
#include<stdio.h>
void main()
{
int i,a;
int k;
printf("Enter any integer for table: ");
scanf("%d",& a);
printf("\n the table of %d: \n",a);
for(i=0;i<=10;i++)
{
k=i*a;
printf(" %d X %d = %d \n",a,i,k);
}
}
Results:
25 | P a g e
Code (with breakpoint):
Results:
Run again:
Run again:
Run again till the end of the program:
26 | P a g e
Conclusion:
In this lab, we successfully gained practical experience with Code Composer Studio (CCS),
learning to configure and build projects while using breakpoints and the watch window. Through
the implementation of the tasks, we developed a deeper understanding of C programming
fundamentals, including array manipulations, loops, and decision-making structures. This
experiment enhanced our ability to troubleshoot and optimize code, reinforcing essential
debugging techniques that are critical for DSP development and embedded systems
programming.
27 | P a g e