You are on page 1of 12

Debugger Enhancements

using
Debug Scripts

---Siva.J
What is debug script?
• Functions to extend the capabilities of the
µVision2 debugger.
• Used to generate external interrupts, log
memory contents to a file, update analog
input values periodically, and input serial
data to the on-chip serial port.
• Utilizes a subset of the C programming
language.
Capabilities & Restrictions
• Flow control statements if, else, while,
do, switch, case, break, continue, and
goto may be used.
• Variables are declared in the same way as
they are declared in ANSI C.
• Arrays are not allowed.
• Type of the file is Initialization File (.ini)
How to use?
• To invoke or run a debug function you
must type the name of the function and
any required parameters in the command
window.
• Supports the three classes of functions:
Predefined Functions,
User Functions, and
Signal Functions.
Predefined Functions
• Provided to assist the user and signal functions
you create.
• void rwatch (address) Delay execution of
signal function until the specified memory
address is read.
• void wwatch (address) Delay execution of
signal function until the specified memory
address is written.
• void swatch (ulong states) Delay execution of
signal function for the specified number of
seconds.
• void twatch (float seconds) Delay execution of
signal function for the specified number of CPU
states.
Predefined Functions (contd.)
• uchar _RBYTE (address) Read char on
specified memory address
• uint _RWORD (address) Read int on
specified memory address
• ulong _RDWORD (address) Read long on
specified memory address
• float _RFLOAT (address) Read float on
specified memory address
• double _RDOUBLE (address) Read double on
specified memory address
Predefined Functions (contd.)
void _WBYTE (address, uchar val) Write char on
specified memory address
void _WWORD (address, uint val) Write int on
specified memory address
void _WDWORD (address, ulong val) Write long
on specified memory address
void _WFLOAT (address, float val) Write float
on specified memory address
void _WDOUBLE (address, double val) Write
double on specified memory address
The swatch function may be called only from
within a signal function.
Calls outside a signal function are not allowed and
result in an error message.
User Functions
• User functions are functions you create to use
with the µVision2 debugger.
User functions begin with FUNC keyword
FUNC return_type fname (parameter_list)
{ statements }
return_type may be: bit, char, float, int, long,
uchar, uint, ulong, void. If no return type is
specified the type int is assumed.
Fname is the name of the function.
parameter_list is the list of arguments that are
passed to the function.
statements are instructions the function carries
out.
Restrictions for User Functions
• Functions with a non-void return type
must return a value.
• User functions may not invoke signal
functions or the twatch function.
• The value of a local object is undefined
until a value is assigned to it.
Signal Functions
• It let you repeat operations, like signal inputs
and pulses, in the background while µVision2
executes your target program.
• Help to simulate and test serial I/O, analog I/O,
port communications, and other repetitive
external events.
• These functions execute in the background while
µVision2 simulates your target program.
• It must call the watch function at some point to
delay and let µVision2 run your target program.
• µVision2 reports an error for signal functions that
never call watch.
Signal Functions (contd.)
• Signal functions begin with the SIGNAL keyword.
SIGNAL void fname (parameter_list)
{ statements }
Fname is the name of the function.
Parameter is the list of arguments that are passed
to the function.
Statements are instructions the function carries
out.
The function definition is complete when the
number of open braces is balanced with the
number of the closing braces (“}”).
Restrictions for Signal Functions
• The return type of a signal function must
be void.
• A signal function may have a maximum of
eight function parameters.
• A signal function may invoke other
predefined functions and user functions.
• A signal function may not invoke another
signal function.
• A maximum of 64 signal functions may be
active simultaneously.

You might also like