T3_ASM_Debug_R2 -...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: T3:
Debugging
a
New
ASM
Project
with
Code
Composer
Studio
(CCS)
Version
4
 
 
 EEL4744
Introduction
to
Microprocessors
–
University
of
Florida,
Electrical
&
Computer
Eng.
 
 Introduction
 The
purpose
of
this
document
is
to
quickly
illustrate
how
to
debug
an
assembly
file
using
the
built
 in
Code
Composer
Studio
debugger.


To
complete
this
tutorial,
you
should
have
completed
the
 previous
tutorial
where
we
created
a
project
example0
which
contained
the
following
files:
 ex0.asm

and
KG_RAM_Link1.cmd




 We
will
basically
pick
up
where
we
left
off
in
the
last
tutorial.

Therefore
you
must
have
ex0.asm
 successfully
assembled
with
no
errors
or
warnings.


This
tutorial
will
illustrate
the
basic
features
 of
the
CCS
debugger
and
how
to
switch
between
simulated
debugging
and
debugging
on
your
 actual
lab
board.

 Procedure
 1.
This
tutorial
assumes
that
you
already
have
assembled
and
linked
ex0.asm
in
project
example0.

 
 2.
Open
up
example0
project
and
assemble/link
to
make
sure
there
are
no
errors
or
warnings
as
 shown
below:
 Document
Revision:
2.0











May,
2009











Authors:
Dr.
K.
Gugel
 
 T3:
Debugging
a
New
ASM
Project
with
Code
Composer
Studio
(CCS)
Version
4
 
 
 
 EEL4744
Introduction
to
Microprocessors
–
University
of
Florida,
Electrical
&
Computer
Eng.
 Document
Revision:
2.0











May,
2009











Authors:
Dr.
K.
Gugel
 3.
Before
we
begin
debugging
the
assembly
code,
we
will
first
need
to
modify
some
of
the
project
 settings
to
produce
map
and
list
files.


To
do
this,
right
click
on
the
example0
[Active
–
debug]
 file
icon
that
is
on
the
left
under
the
C/C++
Projects
title.


Now
scroll
all
the
way
down
and
select
 Properties.


A
new
window
should
open
showing
all
the
project
property
tabs
for
project
 example0.

 4.
Select
C/C++
Build
and
select
the
Tool
Settings
tab
then
select
Linker
Output:
and
then
type
 ex0.map
in
the
Produce
listing
of
input
and
output
sections
in
<file>
(­map_file,
­m)
field
as
 shown
below.


Note:

If
you
can
not
find
this
option
then
your
software
version
automatically
 generates
this
map
file
and
you
can
skip
this
step.

 
 
 Press
the
Apply
button
on
the
bottom
right
to
modify
the
project
properties.


 5.
Next,
scroll
up
the
Tool
Settings
and
select
Assembler
Options:
and
click
on
Generate
listing
 file
and
Generate
asm
extended
warnings
as
shown
in
the
next
snapshot.

This
will
tell
the
 assembler
to
create
a
list
file
and
also
to
give
more
information
if
a
warning
occurs
during
 assembly
or
link
time.
 T3:
Debugging
a
New
ASM
Project
with
Code
Composer
Studio
(CCS)
Version
4
 
 
 
 EEL4744
Introduction
to
Microprocessors
–
University
of
Florida,
Electrical
&
Computer
Eng.
 Document
Revision:
2.0











May,
2009











Authors:
Dr.
K.
Gugel
 
 Press
Apply
and
OK
on
the
bottom
right
to
effect
the
changes
and
exit
the
properties
window.


 
 6.

Now
press
the
Rebuild
Active
Project
icon
on
the
top
toolbar
(leftside)
to
assemble/link
the
 code.

Next
open
ex0.map
by
pressing
File
>
Open
File
…
and
clicking
into
the
Debug
directory
to
 select
the
file.

Repeat
for
the
list
file,
ex0.lst.


 
 T3:
Debugging
a
New
ASM
Project
with
Code
Composer
Studio
(CCS)
Version
4
 
 
 
 EEL4744
Introduction
to
Microprocessors
–
University
of
Florida,
Electrical
&
Computer
Eng.
 Document
Revision:
2.0











May,
2009











Authors:
Dr.
K.
Gugel
 The
map
file,
ex0.map,

shows
the
physical
addresses
for
each
section
of
code
placed
in
DSP
 internal
SRAM:
.data,
.text
and
.bss







The
map
file
also
shows
all
the
addresses
of
the
variables
 that
were
set
as
global
variables
in
the
ex0.asm
file.



The
ex0.lst
file
identifies
all
the
data
and
 program
(DSP
instructions)
placed
in
each
individual
section.


Data
variables
are
usually
placed
in
 the
.data
section
while
program
is
placed
in
the
.text
section.


Run‐time
results
are
then
placed
in
 the
.bss
section.


Each
of
these
section’s
physical
address
is
set
in
the
command
linker
file
 ‘KG_RAM_Link1.cmd’.



We
are
now
almost
ready
to
begin
debugging
(stepping
through)
code.
 7.
There
are
two
types
of
debugging
modes
that
we
can
use:
real
hardware
or
simulated.


In
the
 case
of
real
hardware
debugging,
we
attached
our
lab
board
to
our
laptop
running
CCS
and
 download
and
step
through
our
assembly
code
using
the
actual
F28335
DSP
mounted
on
our
lab
 board.

In
the
case
of
simulated
debugging,
we
don’t
have
to
have
our
lab
board
attached
and
can
 step
through
our
assembly
code
using
the
simulated
debugger
feature
found
in
CCS.


We
will
 begin
with
this
mode
so
that
you
can
see
that
you
can
write
&
debug
code
with
only
your
laptop
 and
no
other
attached
hardware.



 8.

To
debug
using
the
simulator,
we
will
have
to
tell
CCS
that
our
target
is
simulation
and
not
our
 lab
board.

Recall
that
in
the
last
tutorial
we
created
a
new
Target
Configuration
file
to
use
the
 XDS100
programmer/emulator
and
TMS320F28335
DSP.


If
you
double
click
on
example0.ccxml
 on
the
left
you
will
see
these
settings.

These
are
used
to
load
code
and
debug
using
our
lab
board.

 
 Now
we
will
add
a
new
Target
Configuration
File
by
pressing
Target
 
New
Target
 Configuration.

Type
in
a
filename
NoBoard
to
remind
us
this
target
configuration
is
for
 simulation
only.

Just
to
be
sure
the
file
is
placed
in
our
example0
directory,
un‐check
the
Use
 default
location
and
select
/example0
as
the
destination
directory.


Now
click
Finish.

A
new
 window
should
now
appear
that
is
titled
NoBoard.ccxml.

 
 
 T3:
Debugging
a
New
ASM
Project
with
Code
Composer
Studio
(CCS)
Version
4
 
 
 
 EEL4744
Introduction
to
Microprocessors
–
University
of
Florida,
Electrical
&
Computer
Eng.
 Document
Revision:
2.0











May,
2009











Authors:
Dr.
K.
Gugel
 Set
Connection
to
Texas
Instruments
Simulator
and
check
the
Device
that
says
F283x
CPU
 Cycle
Accurate
Simulator
as
shown
in
the
snapshot.

Close
and
save
the
file.

You
will
see
it
show
 up
on
the
left
as
part
of
the
project
files.


 
 9.
Right‐click
the
NoBoard.ccsxml
file
and
select
Set
as
Active
Target
Configuration
to
tell
CCS
 we
are
going
to
simulate
debugging
instead
of
using
our
actual
DSP
on
our
lab
board.




 NoBoard.ccxml
should
now
be
the
active
target
configuration
shown
on
the
left.
 
 10.

Finally
we
can
start
the
debugger
by
pressing
the
small
icon
that
looks
like
a
six
legged
insect.

 Do
so
and
go
to
View
to
open
a
window
for
registers
and
another
for
memory.


Expand
the
 registers
+
icon
to
see
the
cpu
registers.
i.e.
ACC,
P,
XT,
etc.


Type
0xa000
in
the
field
on
the
 memory
window
and
set
the
pull‐down
next
to
this
field
to
program.

You
can
see
the
variables
 placed
into
memory
using
the
assembler
directives
in
the
data
section
of
ex0.asm.
 
 Scroll
down
to
the
PC
(program
counter)
in
the
Registers
window
and
verify
that
it
is
set
to
 0x9000.


This
is
where
our
code
begins
in
ex0.asm.


Begin
stepping
the
code
by
pressing
the
step
 into
arrow
that
is
just
to
the
right
of
the
red
Terminal
All
rectangle
(used
to
exit
debugging).


 T3:
Debugging
a
New
ASM
Project
with
Code
Composer
Studio
(CCS)
Version
4
 
 
 
 EEL4744
Introduction
to
Microprocessors
–
University
of
Florida,
Electrical
&
Computer
Eng.
 Document
Revision:
2.0











May,
2009











Authors:
Dr.
K.
Gugel
 Scroll
up
to
ACC,
XAR0‐XAR2
registers
and
observe
how
they
change
when
the
code
is
single
 stepped.


In
the
memory
window,
type
in
0xb000
and
step
through
the
first
example
that
adds
 three
ASCII
characters.
.
You
need
to
also
select
Enable
Continuous
Refresh
in
the
memory
box
 to
see
the
memory
changes
when
you
step
your
code.


Notice
that
0x00D6
(the
sum
of
the
three
 characters)
is
written
into
0xb003
(which
is
the
address
associated
with
the
sum
label).


 
 11.
Single
step
through
the
remaining
code
and
again
observe
the
results
being
written
into
 memory
locations
0xb000‐0xb003.



This
program
will
be
covered
in
great
detail
during
our
 class
lectures
so
it
is
very
important
to
attend
class
to
learn
about
the
F335
addressing
modes
 and
instruction
set.




 
 12.
If
you
would
like
to
run
the
program
again,
press
the
Reset
CPU
icon
and
then
press
the
 Restart
icon.



Check
to
make
sure
the
PC
is
starting
again
at
0x9000.


A
Dissassembler
window
 may
pop
up
which
blocks
the
Registers
window
you
opened
earlier.

You
may
close
this
but
first
 notice
that
this
shows
the
associated
machine
code
for
our
program
beginning
at
0x9000.


 To
terminate
the
debug
session,
press
the
red
Terminate
All
icon.

Note:
Sometimes
it
takes
a
few
 seconds
to
exit
debugging
(due
to
CCS
variables
being
removed
from
operation)
so
patiently
wait
 until
CCS
returns
to
code
assembly/link
mode.


 
 
 
 FAQ
Relating
to
ASM
Debugging:
 
 1.
When
I
re‐run
the
debugger
to
execute
my
code,
I
noticed
that
the
XAR0‐XAR2
registers
already
 had
non‐zero
values
in
them.

So
I
zeroed
them
out
by
clicking
on
them
and
then
ex0.asm
did
not
 run
properly.

Why
is
this?

What
happened?
 
 When
you
re­run
the
debugger
by
pressing
Reset
CPU
and
Restart,
several
instructions
are
pre­ fetched
and
executed
due
to
the
pipelining
architecture
of
the
CPU.


Note:
CPU
pipelining
will
be
 further
discussed
in
class.


Instead
you
should
reset
&
restart
and
simply
leave
the
registers
alone
 and
step
your
code
as
before.


 
 2.

When
I
step
through
my
code,
I
noticed
that
it
sometimes
takes
a
couple
more
instructions
to
 execute
before
results
are
actually
written
to
memory.


In
other
words,
even
though
I
stepped
 through
an
instruction
that
moves
a
register
value
to
SRAM,
I
don’t
see
memory
change
until
a
 couple
more
instructions
are
stepped.




 
 
 T3:
Debugging
a
New
ASM
Project
with
Code
Composer
Studio
(CCS)
Version
4
 
 
 EEL4744
Introduction
to
Microprocessors
–
University
of
Florida,
Electrical
&
Computer
Eng.
 Document
Revision:
2.0











May,
2009











Authors:
Dr.
K.
Gugel
 
 Again
I
believe
that
this
is
due
to
the
pipelining
nature
of
the
CPU.

Most
likely
it
was
using
the
CPU
 address
and
data
bus
to
pre­fetch
new
instructions
and
therefore
waited
several
cycles
later
to
 perform
the
memory
write
cycle.

This
will
effect
when
we
view
our
results,
however
it
is
not
a
 problem
once
we
are
running
at
full
speed
on
our
board.


 
 3.
I
am
an
engineerd
and
I
love
this
new
tool.

Someday
I
will
create
new
products
with
this
DSP
so
 that
others
will
have
to
work
for
me.

Therefore
I
would
like
to
know
how
to
debug
ex0.asm
on
my
 lab
board
so
that
I
can
begin
experimenting
with
real
hardware.

How
can
I
do
this?
 
 Make
sure
the
debugger
is
terminated
by
pressing
the
red
Terminate
All
icon.

Next
plug
in
your
lab
 board
and
right­click
the
example0.ccxml
target
configuration
file
and
Set
as
Active
Target
 Configuration.

We
are
telling
the
CCS
application
that
we
now
want
to
use
our
lab
board
as
the
 target
device
for
download/debug.

Now
press
the
debug
(insect)
icon
as
was
performed
earlier
in
 simulated
mode
and
step
code
as
was
done
earlier
in
this
tutorial.

 ...
View Full Document

This document was uploaded on 07/11/2011.

Ask a homework question - tutors are online