BD32 Version 1.2
================
May, 1994
Introduction to BD32
====================
BD32 ("Background mode Debugger") is a debug monitor for any Motorola
microcontroller which is based on the CPU32 processor core. This includes
(currently) the MC68330, MC68331, MC68332, MC68F333, and the MC68340. BD32
runs on a host IBM compatible PC, controlling the prototype through the
background debug mode (BDM) interface on CPU32. The Motorola BCC Development
Interface (BCCDI) card may be used; the interface to the BCCDI is done using
either the COM1 or COM2 serial RS-232 port on the PC. The BDM signals may also
be controlled directly by the PC through a special adapter connected to the
PC's parallel printer port, LPT1 or LPT2. Motorola offers an adapter card
called the ICD card, part no. M68ICD32. Alternatively, the user may
construct his own from a circuit schematic included in this archive file.
(The construction details for this adapter are given later in the section
'Connections - using Cable to BDM Connector').
BD32 presents a command-line-driven debug environment. The command
set is very similiar to that presented by the CPU32Bug software
resident in the Business Card Computer's EPROM. The key difference is
that since BD32 controls the processor through the the Background Mode
Interface of the CPU32 processor core, no user resources on the
microcontroller are needed to achieve the emulation. This means
that the chip selects which are connected to the EPROM and RAM on the
BCC may be disconnected and used in the target application. Also the on-chip
SCI port, which is the console port for CPU32Bug, is not required and may
be used in the target application. Thus a true transparent emulation of
the microcontroller is achieved, similiar to Motorola's EVM and EVS series
of emulators for the 8-bit microcontrollers.
This approach to program debugging brings other benefits as well. The BCCDI
card has on it a breakpoint gate array, which allows 4 hardware
breakpoints. This is used by BD32 via the 'BR' (breakpoint) commmand.
BD32 also supports more sophisticated debug capabilities such as symbol
support. Since BD32 resides on a host PC rather than in the user's
target application, more resources are available to allow this type of
feature.
Connections - using BCCDI card
==============================
To operate with the BCCDI, BD32 requires that the 68HC11 on the DI
board contain software version 1.00 through 1.13. This BCCDI may be
identified by the presence of the XC68HC811E2 microcontroller on the
board; the later version of the DI software, implemented with the
XC68HC711E9 microcontroller, will not work with BD32. The BCCDI
must be connected to the PC through either COM1 or COM2 serial ports.
One drawback of using the DI card is that its serial protocol is rather
inefficient, making for slow program downloads. By using the parallel
printer port adapter, download speed will increase approximately by a
factor of five.
Connections - using Motorola's ICD32
====================================
BD32 version 1.2 and later contains a driver to allow control of the target
microcontroller through a product called ICD32, available from Motorola under
part number M68ICD32. This board connects to an IBM-compatible PC via its
parallel printer port, and has a ribbon cable which connects to an 8 or 10-pin
BDM connector on the target system. BD32 can control the ICD card on either
the LPT1 or LPT2 printer ports of the PC.
Connections - using Cable to BDM Connector
==========================================
BD32 can also control the target microcontroller through a public-domain
adapter circuit. This adapter uses two commonly available logic chips, a
74HC132 quad Schmitt NAND gate and a 74HC76 dual J-K flip flop. The
schematic for the circuit is in the disk file 'bdm-if.sch' (created under
Orcad) which should have been included with this documentation. If you do
not have access to the Orcad schematic editor program, the file 'bdm-if.prn'
is the same schematic formatted for output to an Epson-compatible dot-matrix
printer. Simply copying this file to your printer will produce a hard
copy of the schematic for the adapter. NOTE: the unarchived size of this
file is about 500 Kbytes, so you may want to use your de-archiving utility to
dump the file directly to your printer if you are short of hard disk
space! This may be done with the following DOS command (using the 'pkunzip'
de-archive utility from PKWare, Inc.):
pkunzip -p bd32v1-2 bdm-if.prn
The adapter circuit will operate with either the LPT1 or LPT2 parallel
ports on your PC compatible computer. The 8-pin connector labeled 'BCC
Background Mode Connector' should be plugged into the corresponding
8-pin connector on the Business Card Computer (P3 on the 68332 BCC) or
connector P11 on the 68332 Platform Board (PFB).
Operation
=========
After the DI is connected and powered up, BD32 is invoked by entering
'BD32' at the PC-DOS command line. BD32 will support either the
normal 25-line display, or the 50-line VGA or 43-line EGA display
mode; whichever mode is in use when BD32 is executed will be used by
BD32. If the user has access to a VGA or EGA display, it is
recommended that BD32 be used with the 43/50 line mode, as it greatly
improves the usability of the program.
BD32 starts by looking for the disk file 'bd32.cfg' in the default
disk drive and directory, or in the directory from which 'bd32.exe' was
executed. If it finds the file, it reads the first two lines to determine
the communications baud rate and I/O port to use to talk to the target.
Four ports are supported, COM1, COM2, LPT1, and LPT2. If 'bd32.cfg' is
not found, or if it is found but there is an illegal value entered in the
file, then the interface port is not configured and no target debug
operations can proceed until the port is selected (using the 'port' command,
see below). If it is possible to configure the port, then communication
begins with the target system (indicated by the status line at the bottom
of the screen).
An example 'bd32.cfg' might look like this:
COM1
9600
The above example configures BD32 to use the BCC Development Interface board,
connected to COM1 serial port at a baud rate of 9600 baud. BD32 supports any
rate from 110 baud to 9600, but the BCCDI can only be configured for either 9600
baud or 1200 baud. 9600 baud is recommended for best operation.
Another example for 'bd32.cfg' is shown below:
LPT1
1
This example tells BD32 to use the BDM adapter connected to parallel
port LPT1. When the parallel port is used, the second parameter is not
really a 'baud rate'. It actually specifies the a delay count to use when
transferring data serially to the BDM interface. This is needed because if
the target will be running at slow CPU clock rates, the PC can overrun the
BDM interface and data transfers will not execute properly.
The table below serves as a guide to determine the minimum setting for this
parameter. The parameter actually used may need to be set higher to account
for variations in external hardware, such as cables and interface circuit
construction.
PC Clock Speed
(in MegaHertz) Delay Parameter
===============================================================
Processor: XT 286,386 486 Pentium
4.77 0 0
8 0 0
10 0 0
12 0
16 1
20 2 10
25 3 12
33 5 15
40 8 20
50 25
60 30 75
66 35 85
75 (est.) 40 95
83 (est.) 50 110
100 (est.) 60 130
===============================================================
Here is another example which uses the Motorola ICD card on parallel printer
port LPT2:
ICD2
5
The keyword 'ICD' indicates that the Motorola ICD card is being used; the number
after the 'ICD' keyword indicates to which parallel printer port (LPT1 or LPT2)
the ICD card is connected. The '5' parameter specifies a delay of 5 delay loops
per bit.
After the configuration file has been read, BD32 looks at the command line
with which it was invoked. Any text which the user entered after the name
'BD32' will be executed as a BD32 command. Multiple commands may be
separated with the comma (,) character. For example, invoking BD32 with
the following DOS command line
BD32 md $4000
will cause BD32 to immediately display target memory at address $4000,
after it finishes initialization.
After all commands on the command line have been executed, BD32 will
present a prompt and wait for the user to type a command. As on the DOS
command line, the BD32 command line typed by the user may contain multiple
commands separated by the comma character. Also, the user may repeat
execution of the previous command typed, simply by pressing the 'enter' key.
BD32 Screen Display
===================
When BD32 starts up, it sets up the screen display with a single status
line at the bottom, and the remainder as a scrolling command window.
The user is prompted for command input here, and all command output is
displayed here as well. This is the standard 'glass teletype' style
display which is so commonly used.
BD32 shows the status of the target system on the bottom line of the
PC's screen. If no communications have been established with the target
system, then the status line shows simply a copyright message. When
communication is established with the target microcontroller, then the status
line will show the state of the HALT, FREEZE, and RESET signals from the
target microcontroller, as well as the processor state ('RUNNING' or 'STOPPED').
This is updated approximately 20 times per second.
NOTE: when using the parallel adapter circuit, the status of the HALT
signal is not available from the BDM connector and so is not shown on
the screen. The status line update rate is much faster (about 200 times/second)
and the status line can also indicate when the program has stopped on a
breakpoint, by displaying 'BRKPNT' instead of 'STOPPED' in the CPU status field.
If the user desires, a 'windowed' display may be substituted for this non-
windowed 'glass teletype' interface. The command 'window on' enables
the windowed display.
When using the windowed display, BD32 formats the screen into three 'panels'
plus the status line. At the top of the screen is a panel showing the contents
of the target CPU registers. This panel is updated whenever the target CPU
stops execution, whether from a breakpoint, user command, or other reason.
The middle panel displays the contents of memory, either a disassembly into
CPU32 mnemonics ('DASM' command) or a memory hex-ASCII display ('MD'
command). Each time the target CPU stops execution, this panel is updated to
show the code around to location addressed by the target CPU program counter.
The instruction pointed to by the program counter is highlighted in cyan; any
visible breakpoints are highlighted in red, and 'B*' is displayed at the far
left of the disassembly. Whenever the user enters the 'MD' (memory
dump) command, its output is also displayed in this panel; however it
will be replaced by the disassembled code again when the next trace
('T') or step ('S') command is issued.
The bottom panel provides command line entry for the user. BD32
displays a prompt here when ready for commands, and most commands
display their results here also.
The command 'window off' will restore the non-windowed user interface.
Screen Colours
==============
BD32's default display colours are fine for use on a colour CRT, but some
systems such as laptop computers do not display gray scales very well. BD32
Version 1.2 and later allows the user to set screen colours in the
configuration file 'bd32.cfg'.
If the configuration file contains more than two lines of text, the
following lines are scanned and converted to colour attributes to define the
colour settings for the screen display. The attributes are read, line
by line, from the config file in the following order:
_______________________________________________________________________________
Line Number Attribute Description Default
in bd32.cfg Value*
3 Command Output Colour Attribute used to display 30
command output
4 Command Input Colour User input at command prompt 31
5 Prompt Colour Command prompt ("BD32->") 23
6 Register Display Colour Used to highlight CPU register 31
display
7 Breakpoint Colour Colour used to highlight 79
breakpoint locations in
disassembled code
8 PC Colour Used to highlight code 48
addressed by Program Counter
9 Status Line Colour Used for non-highlighted 112
characters on status line
(bottom of screen)
10 Status Item Colour Colour used for highlighted 116
items on status line
11 Border Colour Colour used to draw borders 31
around screen panels
* - See colour table at end of this section
_______________________________________________________________________________
Reaching the end of the configuration file, or any line of text in the
configuration file which cannot successfully interpreted as a decimal
number, will cause BD32 to stop reading the configuration file.
Colour attributes are specified in decimal. They correspond to the
attributes used by the IBM PC's display adapters hardware. Both foreground and
background colour can be specified, as well as intensity.
To calculate the required attribute value, take the desired foreground and
background colour from the table below, and add them together. To cause
the character to blink, add the value 128 to the result. Then use a
text editor to enter the value at the appropriate line in the 'bd32.cfg'
disk file, and BD32 will then use that attribute.
Foreground Colour Value Background Colour Value
=====================================================================
Black 0 Black 0
Blue 1 Blue 16
Green 2 Green 32
Cyan 3 Cyan 48
Red 4 Red 64
Magenta 5 Magenta 80
Brown 6 Brown 96
White 7 White 112
Gray 8
Light Blue 9
Light Green 10
Light Cyan 11
Light Red 12
Light Magenta 13
Yellow 14
Bright White 15
BD32 Symbol Support
=====================
BD32 allows the user to enter symbols in addition to hex and decimal
constants when entering parameters for commmands. This is implemented
by the 'set' command. For example, to display a block of memory, the
MD command may be used as shown below:
md $4000 (display 256 bytes starting at hex $4000)
md 0x4000 (alternate 'C'-like form of expressing hex number)
md 16384 (same as above, only using decimal number)
set start $4000 (gives the symbol 'start' the hex value $4000)
md start (looks up the value of start, uses that as starting
address)
The registers in the target CPU have their names pre-defined in the symbol
table, and any references to these names will return the value contained in
the register. The user should not create symbols which have the same names
as CPU registers, such as A1, D3, PC, VBR etc.
Also, it is important to remember to prefix any hex numbers with the '$'
character or with '0x'. Failing to do this can lead to some interesting
results!
BD32 Expression Evaluation
==========================
In addition to supporting symbols, BD32 allows command parameters to be
specified in the form of a complex expression. Building on the previous
example, the MD command may also have the following form:
md $4000 (use the hex value $4000 as starting address)
set start $4000 (define a symbol)
md start+2*3 (finds value of 'start', and adds 6 to it)
md (start+2)*3 (finds value of 'start', adds 2, multiplies the
result by 3)
In general, any command which needs a numeric parameter will accept an
expression to define that parameter. The form of the expression is the
same as the 'C' programming language, in that most of the same operators
are allowed and they follow the same precedence as the 'C' language.
Whenever an error is detected in the syntax of an expression, the user is
notified, either by displaying the erroneous line and a pointer underneath the
offending character, or displaying the name of the undefined symbol depending
on the type of error encountered. Three types of errors are possible:
undefined symbols (usually a misspelled symbol name), illegal characters (an
unrecognized character in an expression), or illegal operators (an
unrecognized sequence of operator characters).
Below is a list of operators accepted by BD32, in order of decreasing
precedence.
Symbol Name or Meaning Associativity
----------------------------Highest Precedence--------------------------------
( ) Parentheses Left to right
------------------------------------------------------------------------------
! Logical NOT Right to left
~ Bitwise NOT
- Minus
*
[<.B|W|L>] Indirection - get value at memory address using given
size (default size is word if non specified)
------------------------------------------------------------------------------
* Multiply Left to right
/ Divide
% Remainder
------------------------------------------------------------------------------
+ Add Left to right
- Subtract
------------------------------------------------------------------------------
<< Left shift Left to right
>> Right shift
------------------------------------------------------------------------------
< Less than Left to right
<= Less than or equal to
> Greater than
>= Greater than or equal to
------------------------------------------------------------------------------
== Equal Left to right
!= Not equal
------------------------------------------------------------------------------
& Bitwise AND Left to right
------------------------------------------------------------------------------
^ Bitwise exclusive OR Left to right
------------------------------------------------------------------------------
| Bitwise OR Left to right
------------------------------------------------------------------------------
Indirection
===========
Some C operators, such as the increment/decrement operators ++ and --, are
not supported since they make no sense in this context. One operator, the
indirection operator '*', was modified slightly for use with CPU32 assembly
language. In C this operator might be used in this way:
a = *pointer + 6;
This would also be legal in BD32, but for the purposes of assembly language
debugging it is important to be able to specify the size of the operand (in
the C language it is specifed when the symbol is defined). So in BD32 it
might be used this way:
md *table.l + 6
In this case the '*' causes BD32 to retrieve the value of the symbol
'table'. This value is used as the address for a memory reference. The value
stored in that memory location will be retrieved using a long word memory read
and added with the value 6. The result is the address from which the
memory dump command will start displaying the contents of memory.
The '.b' following the symbol specifies that a byte access should be
performed on the address defined by the symbol 'table'. Other size specifiers
which may be used are '.w' and '.l', specifying word or long accesses. If no
specifier is used then the default size is word.
Numeric Constants
=================
In BD32 numeric constants may be one of three forms:
0x1234 hexadecimal
$1234 hexadecimal
1234 decimal
BD32 Commands
=============
Following is a brief description of each of the commands available in BD32.
Each command which needs a numeric parameter, for example an address, will
typically proceed from the address specified the last time the command was
used; for example, if the command "md $100 $17f" was typed, typing "md" later
would display memory starting at address $180.
Some commands such as "md" allow an option to be entered. This option may
take one of four forms:
;b specifies operation on byte data (8 bits)
;w " " " word " (16 bits)
;w " " " long " (32 bits)
;di " " using code assembly/disassembly
For example, if "md $100 ;b" was entered, the memory would be displayed as
byte values. If "md $100 ;di" was entered, a disassembly is done starting
at address $100. If no option is entered, then ";w" (16 bit data) is assumed.
Almost all commands will work whether the CPU32 is running or stopped. If
the CPU32 is running when a command is typed by the user, if that command
needs to access memory or CPU registers then BD32 will stop the processor
momentarily while it retrieves the necessary information, then restart it
again after BD32 has what it needs.
A summary of the commands available may be shown on the screen while
debugging, by typing the command 'help'.
Note that when target memory is accessed by BD32, the default Function Code
used to perform these accesses is 5 (supervisor data space). This may be
changed by the user (see 'FC' command below).
BD32 contains a facility allowing the user to extend the command set of BD32.
If the user enters a command which does not match the name of a built-in BD32
command, then BD32 will search the current DOS directory, and the directory from
which BD32 was executed (DOS version 3.0 and newer only), looking for a disk
file with the same name as the command but with a filename extension of '.d32'.
This file should contain a CPU32 assembly language program, stored in the
Motorola standard S-record format. If such a file is found, its contents are
downloaded to the target MCU and the program is executed. If the file is not
found, BD32 reports 'undefined command' to the user.
Programs which are downloaded and executed in this manner are called
'Target-Resident Command Drivers', and they have access to all resources
available on the host PC, such as the display and keyboard, disk files,
etc. This facility may be used to create new BD32 commands which
perform target-dependant tasks, such as on-chip EEPROM programming,
self-test, etc. For more information on these command drivers, see
the section entitled 'Using Target-Resident Command Drivers with BD32'.
Memory Display/Modify Commands
==============================
BF [;