You are on page 1of 19

Instructor Manual Designed by Engr.

Wania Anoosh

AIR UNIVERSITY
DEPARTMENT OF ELECTRICAL AND COMPUTER ENGINEERING

EXPERIMENT NO: 03

Lab Title: Introduction to Code Composer Studio and debugging using


breakpoints andwatch window
Student Name : Wali Muhammad. Reg. No: 200750
Usman raza 200738
MUHAMMAD SALLAL 200778
TALHA NAMEEM 200706

Objective: 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
LAB ASSESSMENT:

Excellen Good Average Satisfacto Unsatisfacto


Attributes t (5) (4) (3) ry (2) ry (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:


Excellen Good Average Satisfacto Unsatisfacto
Attributes
t (5) (4) (3) ry (2) ry (1)

Data presentation

Experimental results

Conclusion

Total Marks: Obtained Marks:


1|Page
Instructor Manual Designed by Engr. Wania Anoosh

Experiment 05

Introduction to Code Composer Studio and 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
Instructor Manual Designed by Engr. Wania Anoosh

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
Instructor Manual Designed by Engr. Wania Anoosh

After accepting the license agreement, select the installation folder directory.

Select custom as the setup type.

4|Page
Instructor Manual Designed by Engr. Wania Anoosh

Select the processor architectures and click next. Select all default components and click on next.

5|Page
Instructor Manual Designed by Engr. Wania Anoosh

Select Spectrum Digital Emulator and click next.

6|Page
Instructor Manual Designed by Engr. Wania Anoosh

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. A new window will appear after creating new project
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.

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");
}

7|Page
Instructor Manual Designed by Engr. Wania Anoosh

• 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.

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.

8|Page
Instructor Manual Designed by Engr. Wania Anoosh

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

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;

9|Page
Instructor Manual Designed by Engr. Wania Anoosh

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 )
{
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;

10 | P a g e
Instructor Manual Designed by Engr. Wania Anoosh

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.
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" );}
11 | P a g e
Instructor Manual Designed by Engr. Wania Anoosh

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" );
}
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

12 | P a g e
Instructor Manual Designed by Engr. Wania Anoosh

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;
}
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

13 | P a g e
Instructor Manual Designed by Engr. Wania Anoosh

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;
}

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

14 | P a g e
Instructor Manual Designed by Engr. Wania Anoosh

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.

Project Debugging:
Go to Run button on main menu and click Debug. The following window appears along with the code
file and output console.

15 | P a g e
Instructor Manual Designed by Engr. Wania Anoosh

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.

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.
After a breakpoint is added, a window appears such that:

Right click on the variable and select Add Watch Expression option, name it, and press OK. A watch
window will appear, and the variable will be added to it. For now, the value stored in this variable is
zero.

Run the program again. The value 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 in Watch Window is updated. The
output at the console is also updated.

16 | P a g e
Instructor Manual Designed by Engr. Wania Anoosh

Lab Tasks:
1. Create an array which contains 5 temperature values in Celsius, such that C = [30, 50, 70, 90,
110]. Convert the temperature values in Celsius to Fahrenheit and display the results on
console.

Code on ccs software

17 | P a g e
Instructor Manual Designed by Engr. Wania Anoosh

2. Write a C program which takes input from user using scanf command and generates factorial
of this number. Display the results on console.

Code on ccs software

18 | P a g e
Instructor Manual Designed by Engr. Wania Anoosh

3. Write a C Program to Compute Quotient and Remainder of a number and display the results
on console.

Code on c compiler

Conclusion.
In this lab we get fimilarize with code composer studio.The first two tasks were
performed in the lab where were integrated with the hardware. We got to know
ho to use debugging using breakpoints and watch window we first do certin
settings to integrate software with the hardware than write a code in c language
for the above stated tasks than we build the and debugged the program.

19 | P a g e

You might also like