Intro To Code Composer Studio (CCS) : Resets
Intro To Code Composer Studio (CCS) : Resets
CREATING PROJECTS
Hit Finish
Your project.pjt should be in the Project View window.
void main()
{
printf(Begin\n);
.sect .mydata
.short 0
.short 7
.short 10
.short 7
.short 0
.short -7
.short -10
.short -7
.short 0
.short 7
Often times you can use an existing .cmd file. But lets put our data
in a certain part of memory so that we can access it.
Project > Build compiles, assembles, and links all of the files in the
project and produce the executable file lab1.out.
A window at the bottom shows if there are errors.
Project > Rebuild can be used when you have made a change to only
a few files and now wish to compile, assemble, and link with the
changed files.
There are shortcut buttons on the window to do Project Build and
Rebuild. FIND them. They will be useful in the future.
You should have gotten a lot of errors upon building. Scroll up until
you reach the first red line with ERROR! in it. Double click on the
line. The file initmem.asm opens at the line where the error
occurred. Assembly code required that all of the lines in this file
NOT start in the first column. So enter a space at the beginning of
each line in the file and then save the file.
View Memory:
Lets see if the values of our initmem file are in the memory location
we established in the .cmd file.
View > Memory
Type in 0x80000000 in memory location.
Format: 16bit Signed Int
A Memory window appears with the memory addresses and their
contents.
## Write out on a piece of paper the memory locations for your
data.
Why do you think there are two values per memory location?
}
Save it, Rebuild (shortcut button on the top or Debug > Rebuild) ,
and Load it into the DSP memory.
Run it.
Now we are ready to do some more analysis.
**************************************
**************************************
Check a Variable During Program Execution
Before we look at additional debugging and analysis features, lets
modify our main.c program. We will assign a pointer to the
beginning of our data in memory. In this way, we can bring data
into our c program and print the data out.
Double-click on main.c in the project window.
Change the program so that it looks like the following:
#include <stdio.h>
File > Reload to reload the program (we loaded and ran it in the step
before).
void main()
{
int i;
short *point;
point= (short *) 0x80000000;
printf(Begin\n);
for (i=0;i<10;i++)
Highlight the variable point in the line: point = (short*) using the
mouse.
Right click and select Add to Watch Window. A watch window
opens which shows the variable point.
Highlight the variable i in the line: printf([%d] with the mouse.
Right click and select Add to Watch Window. This variable is now
added to the window.
Lets add a subroutine to our C program which will sum the values.
Then we will look at how much time it takes to run the subroutine.
Double-click on main.c in the project window and make the needed
changes so that the following C program results (make sure the
breakpoints are removed).
#include <stdio.h>
void main()
{
int i, ret;
short *point;
point= (short *) 0x80000000;
printf("Begin\n");
for (i=0;i<10;i++)
{
printf("[%d] %d\n",i, point[i]);
}
ret = ret_sum(point,10);
printf(Sum = %d\n,ret);
printf("End\n");
}
int ret_sum(const short* array, int N)
{
int count, sum;
sum=0;
for(count=0; count<N; count++)
sum += array[count];
return(sum);
}
**************************************
Project > Build Options. Choose Compiler and Basic. Choose Opt
Level o0. OK.
Shortcut button Rebuild All or Project > Rebuild All.
File > Load Program Lab1.out.
Highlight ret_sum in the Files pane, right click, and Clear Selected.
Hit shortcut button Run or Debug > Run.
## Record the number of clock cycles which were required for
ret_sum with this level of optimization.
Benchmarking
Now we will benchmark or time the subroutine. In other words, we
will see how long it takes for ret_sum() to run.
Reload the program and then choose Profiler > Start New Session
and give your session a title, Lab1. A profile window comes up in
the bottom.
Double-click on main.c in the project window. Put your cursor on
the line: int ret_sum(const short* array, int N).
Several shortcut buttons are on the left side of the Profile Window.
Hit the Create Profile Area button. Make sure the type is Function.
The line number corresponds to the beginning of the function since
this is where you placed the cursor. Hit OK.
Now expand Lab1.out under the Files window pane. The function
ret_sum should be there.
Hit the Run shortcut button. The value for the Incl. Total is the
number of clock cycles needed to run the function ret_sum.
## Record this number on a piece of paper.
If you want to redo this exercise, highlight ret_sum in the Files
window pane, right click, and select Clear Selected. Then hit Debug
> Restart. Now Run with the shortcut button.
Repeat the above for the other levels of optimization o1, o2, and o3.