Spnu 129 A
Spnu 129 A
Simulator
Getting Started Guide
IMPORTANT NOTICE
Texas Instruments (TI) reserves the right to make changes to its products or to discontinue any
semiconductor product or service without notice, and advises its customers to obtain the latest
version of relevant information to verify, before placing orders, that the information being relied
on is current.
TI warrants performance of its semiconductor products and related software to the specifications
applicable at the time of sale in accordance with TI’s standard warranty. Testing and other quality
control techniques are utilized to the extent TI deems necessary to support this warranty.
Specific testing of all parameters of each device is not necessarily performed, except those
mandated by government requirements.
Certain applications using semiconductor products may involve potential risks of death,
personal injury, or severe property or environmental damage (“Critical Applications”).
Inclusion of TI products in such applications is understood to be fully at the risk of the customer.
Use of TI products in such applications requires the written approval of an appropriate TI officer.
Questions concerning potential risk applications should be directed to TI through a local SC
sales office.
In order to minimize risks associated with the customer’s applications, adequate design and
operating safeguards should be provided by the customer to minimize inherent or procedural
hazards.
ii
Preface
Notational Conventions
This document uses the following conventions.
- Program listings, program examples, and interactive displays are shown
in a special typeface similar to a typewriter’s. Examples use a bold
version of the special typeface for emphasis; interactive displays use a
bold version of the special typeface to distinguish commands that you
enter from items that the system displays (such as prompts, command
output, error messages, etc.).
Here is an example of a system prompt and a command that you might
enter:
C: MD C:\370HLL
- In syntax descriptions, the instruction, command, or directive is in a bold
typeface font and parameters are in an italic typeface. Portions of a syntax
that are in bold should be entered as shown; portions of a syntax that are
in italics describe the type of information that should be entered. Here is
an example of a command syntax:
pinc pinname, filename
pinc is the command. This command has two parameters, indicated by
pinname and filename.
- Square brackets ( [ and ] ) identify an optional parameter. If you use an
optional parameter, you specify the information within the brackets; you
don’t enter the brackets themselves. Here’s an example of a command
that has an optional parameter:
sim370w [filename] [options]
The sim370w command has two parameters. The both parameters are
optional.
iii
Notational Conventions / Related Documentation From Texas Instruments
- Braces ( { and } ) indicate a list. The symbol | (read as or) separates items
within the list. Here’s an example of a command including a list:
mc portaddress, length, filename, {READ | WRITE}
This provides two choices: READ or WRITE.
Unless the list is enclosed in square brackets, you must choose one item
from the list.
The following books describe the TMS370 and related support tools. To obtain
a copy of any of these TI documents, call the Texas Instruments Literature Re-
sponse Center at (800) 477–8924. When ordering, please identify the book by
its title and literature number.
iv
Trademarks / If You Need Assistance
Trademarks
Microsoft and Windows are registered trademarks of Microsoft Corporation.
PC is a trademark of International Business Machines Corporation.
Pentium is a trademark of Intel Corporation.
XDS/22 is a trademark of Texas Instruments Incorporated.
Contents
vii
Contents
viii
Chapter 1
This chapter helps you install the simulator version of the C source debugger
on a PC running Windows. The debugger is the programmer’s interface to the
TMS370 family simulator. When you complete the installation, turn to Chap-
ter 2, Simulator Features, for more information about using the simulator ver-
sion of the ’370 debugger.
Topic Page
1-1
System Requirements
Hardware checklist
1-2
System Requirements
Software checklist
2) On your hard disk or system disk, create a directory named 370hll. This
directory will contain the ’370 C source debugger software. To create this
directory, enter:
MD C:\370HLL
3) Insert the debugger product disk into drive A. Copy the contents of the
disk:
XCOPY /V /S A:\*.* C:\370HLL
You may want to create a Windows program group and use a program-item
icon to make it easier to invoke the debugger from within the Windows environ-
ment.
A program group contains program-item icons. You can use program groups
to help you organize your icons. To create a program group, follow these steps:
1) From the Windows Program Manager, select File → New. This displays
the New Program Object dialog box.
3) Click on OK. This displays the Program Group Properties dialog box.
5) Click on OK. This displays an empty program group with the name you en-
tered.
1-4
Step 1: Installing the Debugger Software
A program-item icon represents an application that you can run from Windows.
Program-item icons are contained inside program groups. The debugger al-
ready has a standard icon that you can use. To use the standard debugger
icon, follow these steps:
1) If the program group in which you want to place the icon is not already
open, double-click on it to open it.
3) Arrange the windows so you can see the program group and the File Man-
ager at the same time.
5) Drag and drop the [Link] into the program group. An icon that looks
like this displays:
7) In the Program Manager, select File → Properties. This displays the Pro-
gram Item Properties dialog box.
8) Modify the information in the Command Line field to include the options
you normally use at start-up. For a summary of the options that you can
use, see Table 2–1, Summary of Debugger Options, on page 2-2.
- Define environment variables so that the debugger can find the files it
needs.
Figure 1–1 (a) shows an example of an [Link] file that contains the
suggested modifications. Figure 1–1 (b) shows a sample batch file that you
could create instead of editing the [Link] file. The subsections following
the figure explain these modifications.
DATE
TIME
ECHO OFF
PATH statement PATH=C:\WINDOWS;C:\370TOOLS;C:\370HLL
SET D_DIR=C:\370HLL
Environment SET D_SRC=C:\CSOURCE
variables SET D_OPTIONS= –b
SET C_DIR=C:\370TOOLS
CLS
(b) Sample batch file that you create to use with the debugger
1-6
Step 2: Setting Up the Debugger Environment
Define a path to the debugger directory. The general format for doing this is:
PATH=C:\370HLL
This allows you to invoke the debugger without specifying the name of the
directory that contains the debugger executable file.
- If you are creating your own batch file, use a different format for the PATH
statement:
PATH=%PATH%;C:\370HLL
The addition of %path%; ensures that this PATH statement won’t undo
PATH statements in any other batch files (including the [Link] file).
- Identify any directories that contain program source files that you’ll want
to look at while you’re debugging code with D_SRC. Use this format:
SET D_SRC=pathname1 ;pathname2 ...
For example, if your ’370 programs were in a directory named csource on
drive C, the D_SRC setup would be:
SET D_SRC=C:\CSOURCE
- Identify the invocation options that you want to use regularly with
D_OPTIONS. Use this format:
SET D_OPTIONS= [filename] [options]
The filename identifies the optional object file for the debugger to load, and
the options list the options you want to use at invocation. These are the
options that you can identify with D_OPTIONS:
You can override D_OPTIONS by invoking the debugger with the –x op-
tion.
For more information about options, see Section 2.1, Invoking the Debug-
ger, page 2-2.
- If you modify the [Link] file, be sure to invoke it before invoking the
debugger for the first time. To invoke this file, enter:
AUTOEXEC
- If you create your own batch file, you must invoke it before entering
Windows. You’ll need to invoke your batch file any time that you power up
or reboot your PC. For the purpose of this discussion, assume that this
sample batch file is named [Link]. To invoke this file, enter:
INITDB
1-8
Step 3: Verifying the Installation
1) Start Windows.
4) When the debugger window appears, enter the following from the
command line:
load sample
- If you did not set up an icon for the debugger, follow these steps:
1) Start Windows.
2) In the Program Manager or File Manager, select Run... from the File
menu.
Load Break Watch Memory Color MoDe Pin Run=F5 Step=F8 Next=F10
DISASSEMBLY CPU
7189 88 c_int00: MOVW #05dFFh,R021 PC 7189
718d 98 MOVW R021,R01F A 00 B 00
7190 52 MOV #022h,B ST 00 SP 00
7192 fd LDSP
7193 8e CALL 719Dh
7196 8e CALL main
7199 8e CALL exit
719c fa RTI
719d 88 MOVW #0723Dh,R0F
71a1 00 JMP 071C3h
71a3 f4 MOV 3[R0F],A
71a7 d0 MOV A,R0D
71a9 f4 MOV 2[R0F],A
71ad d0 MOV A,R0C
71af 70 INCW #4,R0F
COMMAND MEMORY
0000 00 00 00 00 00 00 00 00 00 00 00 00
000c 00 00 00 00 00 00 00 00 00 00 00 00
Loading [Link] 0018 00 00 00 00 00 00 00 00 00 00 00 00
73 Symbols loaded 0024 00 00 00 00 00 00 00 00 00 00 00 00
Done 0030 00 00 00 00 00 00 00 00 00 00 00 00
>>> 003c 00 00 00 00 00 00 00 00 00 00 00 00
If you see a similar display, you have correctly installed your debugger.
If you don’t see a display, your debugger may not be installed properly. Go back
through the installation instructions and be sure that you have followed each
step correctly; then reenter the command above.
Notes:
1) Using Windows, you can freely move or resize the debugger display on
the screen. If the resized display is bigger than the debugger requires,
the extra space is not used. If the resized display is smaller than re-
quired, the display is clipped. Note that when the display is clipped, it
can’t be scrolled.
2) You should run Windows in either the standard mode or the 386
enhanced mode to get the best results.
1-10
Chapter 2
Simulator Features
This chapter tells you how to invoke the simulator version of the debugger and
introduces the simulator’s basic features. When you finish reading this chap-
ter, refer to the TMS370 Family C Source Debugger User’s Guide. The
TMS370 Family C Source Debugger User’s Guide discusses various aspects
of the debugger interface, including window management, command entry,
code execution, data management, and breakpoints. The book also includes
a tutorial that introduces basic features of the debugger.
Topic Page
2-1
Invoking the Debugger
Here’s the basic format for the command that invokes the debugger:
You can use the D_OPTION environment variable to specify files and options
that you use often. (See the Setting up the environment variables subsection
starting on page 1-7.) You can also specify options that you use often on your
debugger command line. (See the Using a program-item icon subsection on
page 1-5 for information about modifying your command line.)
2-2
Invoking the Debugger
The –b and –bb options override the screen size specified in the [Link] file.
Using –i is similar to using the D_SRC environment variable (see the Setting
up the environment variables subsection starting on page 1-7). If you name
directories with both –i and D_SRC, the debugger first searches through direc-
tories named with –i. The debugger can track a cumulative total of 20 paths
(including paths specified with –i, D_SRC, and the debugger USE command).
The debugger has a minimal debugging mode that displays the COMMAND,
WATCH, and DISP windows only. The WATCH and DISP windows are dis-
played only if you cause them to display (by entering the WA or DISP com-
mands). Minimal mode may be useful when you need to debug a memory
problem.
To invoke the debugger and enter minimal mode, use the –min option.
For more information about debugger windows, see the TMS370 Family C
Source Debugger User’s Guide.
The –profile option allows you to bring up the debugger in a profiling environ-
ment so that you can collect statistics about code execution. Only a subset of
the basic debugger features is available in the profiling environment.
For more information about using the profiler, see the TMS370 Family C
Source Debugger User’s Guide.
If you supply a filename when you invoke the debugger, you can use the –s
option to tell the debugger to load only the file’s symbol table (without the file’s
object code). This option is useful in a debugging environment in which the de-
bugger cannot, or need not, load the object code (for example, if the code is
in ROM). Using this option is similar to loading a file by using the debugger’s
SLOAD command (described in the TMS370 Family C Source Debugger
User’s Guide).
The –t option allows you to specify an initialization command file to use instead
of [Link]. The format for the –t option is:
–t filename
The –v option prevents the debugger from loading the entire symbol table
when you load an object file. The debugger loads only the global symbols and
later loads local symbols as it needs them. This speeds up the loading time and
consumes less memory.
The –v option affects all loads, including those performed when you invoke the
debugger and those performed with the LOAD command within the debugger
environment.
The –x option tells the debugger to ignore any information supplied with
D_OPTIONS. For more information about D_OPTIONS, refer to the Setting
up the environment variables subsection, starting on page 1-7.
2-4
A Sample Memory Map for the Simulator
Because you must define a memory map before you can run any programs,
it’s convenient to define the memory map in an initialization batch file.
Figure 2–1 (a) shows a sample of memory map commands that you could in-
clude in an initialization batch file for the simulator.
The MA commands (described on page 2-6) define valid memory ranges and
identify the read/write characteristics of the memory ranges. The MAP com-
mand enables mapping. (Note that by default, mapping is enabled when you
invoke the debugger.) Figure 2–1 (b) illustrates the memory map defined by
the MA commands in Figure 2–1 (a).
For more information about memory mapping and the initialization batch file,
see the TMS370 Family C Source Debugger User’s Guide.
Figure 2–1. Sample Memory Map for Use With a ’370 Simulator
(a) Memory map commands (b) Memory map for ’370 local memory
ÉÉÉÉÉÉÉÉÉ
MA 0x100,0x100,xram
MA 0x1010,0x10,iram 0x0100 External RAM
ÉÉÉÉÉÉÉÉÉ
MA 0x1020,0x10,iram to 0x01FF
0x0200
ÉÉÉÉÉÉÉÉÉ
MA 0x1030,0x10,siper Reserved
to 0x100F
MA 0x1040,0x10,tiper 0x1010
MA 0x1050,0x10,siper Internal RAM
to 0x101F
MA 0x1060,0x10,tiper
0x1020 Internal RAM
MA 0x1070,0x10,iram to 0x102F
MA 0x2000,0x1000,xram 0x1030
MA 0x4000,0x4000,xrom Serial internal peripheral frame
to 0x103F
0x1040 Timer internal peripheral frame
to 0x104F
0x1050 Serial internal peripheral frame
to 0x105F
0x1060 Timer internal peripheral frame
to 0x106F
ÉÉÉÉÉÉÉÉÉ
0x1070 Internal RAM
to 0x107F
0x1080
to 0x1FFF
0x2000
ÉÉÉÉÉÉÉÉÉ Reserved
ÉÉÉÉÉÉÉÉÉ
External RAM
to 0x2FFF
ÉÉÉÉÉÉÉÉÉ
0x3000 Reserved
to 0x3FFF
0x4000 External ROM
to 0x7FFF
- The length parameter defines the length of the range in bytes. This
parameter can be any C expression.
2-6
Identifying Usable Memory Ranges
Table 2–3. Keywords for Use With the Type Parameter (Continued)
Be sure that the map ranges that you specify in a common object file format
(COFF) file match those that you define with the MA command. Moreover, a
command sequence such as:
ma x,y,ram; ma x+y,z,ram
If you were planning to load two COFF blocks, where the first block spanned
the length of y and the second block spanned the length of z, you would use
the first MA command example. However, if you were planning to load a COFF
block that spanned the length of y + z, you would use the second MA com-
mand example.
Alternatively, you could turn memory mapping off during a load by using the
MAP OFF command. Although the MAP OFF command can be useful, you
need to be sure that you use it correctly. See the Defining a Memory Map chap-
ter of the TMS370 Family C Source Debugger User’s Guide for more informa-
tion about using the MAP OFF command.
- Both the starting address and the length of a memory range that you define
with the MA command must be a multiple of 16 bytes. If you define a range
that is not a multiple of 16 bytes, the debugger ignores the new range and
displays this error message in the display area of the COMMAND window:
Illegal mapping granularity
If you’re defining a peripheral frame, this restriction does not apply.
2-8
Simulating I/O Space
- The length parameter is the length (in bytes) of the file that you are con-
necting to the peripheral port address.
- The filename parameter can be any filename. If you connect a port to read
from a file, the file must exist, or the MC command will fail.
The file is accessed (in read or write mode) during the execution of any instruc-
tion that reads from or writes to the address of the associated memory-
mapped peripheral frame.
Example 2–1 shows how an input peripheral port can be connected to an input
file named [Link].
Assume that the file [Link] contains words of data in hexadecimal format,
one per line, like this:
0A
10
20
.
.
.
Notice that each line starts with a two-digit hex value; anything other than
that on the line is ignored and assumed to be a comment.
Assume that this ’370 instruction is part of your ’370 program. The instruc-
tion reads from the [Link] file:
MOV P022,A MOV instruction reads from file
and loads the read data in register A
Before you can use the MD command to delete a peripheral frame from the
memory map, you must use the MI command to disconnect the peripheral port.
The MI (memory disconnect) command disconnects a file from a peripheral I/O
port. The syntax for this command is:
- The second parameter, READ or WRITE, must match the parameter that
was used when the port was connected with the MC command.
2-10
Simulating Interrupts
In order to simulate interrupts, you must first set up an input file that lists inter-
rupt intervals. Your file must contain a clock cycle and an offset value in the
following format:
[clock cycle, offset] [ ( [clock cycle, offset]...) ] [ rpt {n | EOS} ]
Note that the parentheses are optional and are used for grouping interrupt val-
ues, while repeating a particular pattern.
- The clock cycle parameter represents the CPU clock cycle where you
want an interrupt to occur. Note that the square brackets around clock
cycle and offset are part of the syntax and must be included.
You can have two types of CPU clock cycles:
J Absolute. To use an absolute clock cycle, your cycle value must rep-
resent the actual CPU clock cycle where you want to simulate an inter-
rupt. For example:
[12,0xfa] [34,0xfc] [56,0xfa] [78,0xfc]
An interrupt signal is simulated at the 12th, 34th, 56th, and 78th CPU
clock cycles. Notice that no operation is done to the clock cycle value;
the interrupt occurs exactly as the clock cycle value is written.
J Relative. You can also select a clock cycle that is relative to the time at
which the last event occurred. For example:
[12,0xfa] [+34,0xfc] [55,0xfa] [+20,0xfc]
An interrupt signal is simulated at the 12th, 46th (12+34), 55th, and
75th (55+20) CPU clock cycles. A plus sign (+) before a clock cycle
adds that value to the clock cycle preceding it. As shown in this exam-
ple, you can mix both relative and absolute cycle values in your input
file.
You can choose to use a relative clock cycle value as your first clock
cycle parameter. In this case, the clock cycle value is relative to 0.
- The offset parameter, when added to the interrupt table base address,
represents the interrupt vector location. The debugger reads this interrupt
vector and loads it into the PC. The offset value must be an 8-bit even num-
ber.
For example, the debugger reads your input file and is instructed to gener-
ate an interrupt on LEV1. Assume that the base address in the interrupt
table is 0x7F00 and that your offset value is 0x00FA. The debugger reads
the interrupt vector table at locations 0x7FFA and 0x7FFB to retrieve the
starting value of the PC.
- The rpt {n | EOS} parameter is optional and represents a repetition value.
You can have two forms of repetition to simulate interrupts:
J Repeat a fixed number of times. You can format your input file to re-
peat a particular pattern for a fixed number of times. For example:
[20,0x3e] ([+5,0x24] [+10,0x10]) rpt 4
The values inside of the parentheses represent the portion that is re-
peated. Therefore, an interrupt signal is simulated at the 20th, 25th
(20+5), 35th (25+10), 40th (35+5), 50th (40+10), 55th (50+5), 65th
(55+10), 70th (65+5), and 80th (70+10) clock cycles.
Make sure that n is a positive integer value.
J Repeat to the end of simulation. To repeat the same pattern
throughout the simulation, add the string EOS to the line. For example:
([+100,0xf0]) rpt EOS
An interrupt is generated every 100 clock cycles.
2-12
Simulating Interrupts
For example, to connect the input file myfile to the LEV1 interrupt pin, you
would enter:
pinc lev1, myfile
To verify that your input file is connected to the correct pin, use the PINL com-
mand. The syntax for this command is:
pinl
The PINL command displays all of the unconnected pins first, followed by the
connected pins. For a connected pin, the simulator displays the name of the
pin and the absolute pathname of the file in the COMMAND window.
COMMAND
PIN FILENAME
~~~~~~~~~~~~~~~~~~~~~~~~~~~
LEV1 NULL
LEV2 /370hll/myfile
>>>
When you want to connect another file to an interrupt pin, the PINL command
is useful for looking up an unconnected pin.
To end the interrupt simulation, you must disconnect the pin. You can do this
with the PIND command:
pind pinname
The pinname parameter identifies the interrupt pin and must be either LEV1
or LEV2. The PIND command detaches the file from the interrupt pin. After
executing this command, you can connect another file to the same pin.
When you use the IF/ELSE/ENDIF command sequence, you can use some
predefined constants. These constants evaluate to 0 (false) or 1 (true).
Table 2–4 shows the constants and their corresponding tools.
$$SIM$$ Simulator
One way you can use these predefined constants is to create an initialization
batch file that works for any debugger tool. This is useful if you are using, for
example, both an XDS/22 emulator and the simulator. To do this, you can set
up the following batch file:
if $$XDS22$$
echo Invoking initialization batch file for XDS.
use \370tools
take [Link]
.
.
endif
if $$SIM$$
echo Invoking initialization batch file for simulator.
use \370hll
take [Link]
.
.
endif
.
.
In this example, the debugger executes only the initialization commands that
apply to the debugging tool that you invoke.
2-14
Benchmarking
Benchmarking / Profiling Code Execution
2.7 Benchmarking
The simulator version of the debugger allows you to keep track of the number
of CPU clock cycles consumed by a particular section of code. The debugger
maintains the count in a pseudoregister named CLK. This process is referred
to as benchmarking.
Step 1: Set the program counter (PC) value at the statement that marks the
beginning of the section of code that you’d like to benchmark. (You
can do this either by editing the PC value at the command line or by
setting a software breakpoint at the statement you’d like to bench-
mark.)
Step 2: Set a software breakpoint at the statement that marks the end of the
section of code you’d like to benchmark.
When the processor halts at the second breakpoint, the value of CLK is valid.
To display it, use the ? command or enter it into the WATCH window with the
WA command. This value is valid until you enter another RUN command.
Notes:
1) The value in CLK is valid only after using a RUNB command that is termi-
nated by a software breakpoint. (The maximum value for CLK is 65 535.)
2) When programming in C, do not use a variable named CLK.
A
Area restricted to peripherals
Description You attempted to add a nonperipheral frame range within the
dedicated peripheral area (0x1000 to 0x10FF).
Action Reenter the MA command, specifying a range that is not with-
in 0x1000 to 0x10FF.
C
Cannot connect pin
Description You attempted to connect a pin to a file that the debugger can-
not open.
Action Be sure that the filename was typed correctly. If it was, then:
1) Check the access rights of the file and/or the directory
that contains the file.
2) Reenter the command and specify full path information
with the filename.
2-16
Debugger Messages
F
File already tied to port
Description You attempted to connect to an address that already has a file
connected to it.
Action Connect the file to a mapped port that is not already con-
nected to another file.
I
Illegal mapping granularity
Description You attempted to do one of the following:
- Add a memory range that does not start on an address
that is a multiple of 16 bytes or does not have a length that
is a multiple of 16 bytes. This restriction does not apply
when you’re defining a peripheral range or an expansion
memory range
- Add an expansion memory range that does not start on
an address that is a multiple of 4K bytes or does not have
a length that is a multiple of 4K bytes
Action Choose the appropriate action for the type of memory range
that you are trying to add:
- For a nonperipheral and nonexpansion memory range,
reenter the MA command and specify a range that starts
on an address that is a multiple of 16 bytes and has a
length that is a multiple of 16 bytes.
- For an expansion memory range, reenter the MA com-
mand and specify a range that starts on an address that
is a multiple of 4K bytes and has a length that is a multiple
of 4K bytes.
2-18
Debugger Messages
2-20
Debugger Messages
P
Pinname not valid for this chip
Description You attempted to connect or disconnect an input file to an
invalid interrupt pin.
Action Reconnect or disconnect the input file to an unused interrupt
pin (LEV1 or LEV2).
2-22