Home / µVision User's Guide
C51, C251, C166 Development Tools
BreakSet
The BreakSet command sets a breakpoint for the specified
expression (exp). Breakpoints are program addresses or
expressions that, when true, halt execution of your target program or
execute the specified command ("cmd").
Syntax |
Description |
BreakSet exp , cnt ,
"cmd" |
Set an execution or conditional breakpoint. |
BreakSet READ exp , cnt
, "cmd" |
Set a read access breakpoint. |
BreakSet WRITE exp , cnt
, "cmd" |
Set a write access breakpoint. |
BreakSet READWRITE exp ,
cnt , "cmd" |
Set a read/write access breakpoint. |
Breakpoint parameters:
where: |
|
exp |
is an address specification or an expression
that is evaluated during execution. Refer to Expressions for details. |
cnt |
is an expression that determines the number of
times a breakpoint condition is met before the target program
halts or the specified command is executed. The default count
value is 1. |
cmd |
is a µVision command string that is executed
when the breakpoint triggers. Program execution is not halted.
User-defined and signal functions can be used in the command
expression. In functions, you can set the system variable
_break_ to 1 to
halt program execution. When no command is specified, program
execution is halted. |
Breakpoint types are categorized through the following rules:
-
Access Breakpoint: one of the memory access modes (READ,
WRITE, or READWRITE) was specified.
Memory Access Breakpoints halt program execution or execute a
command when a specific address is read, written, or accessed.
Program execution speed is not affected dramatically, because
expressions are evaluated only when the specified access event
occurs.
Expressions specified for memory Access Breakpoints must
resolve to a memory address and memory type. The following rules
apply:
-
For devices based on 8080 processors and derivatives,
expressions must have fully qualified memory types.
-
Expressions that include multiple objects are not
allowed.
-
Only a few operators (&, &&, <, <=, >,
>=, ==, and !=) are allowed in expressions.
Note
-
When an Access Breakpoint (read or write) is set to
a peripheral register (SFR) in the Simulator, the breakpoint
might trigger even though the application did not access the
peripheral register. This happens because the µVision Simulator
makes no difference between application-driven and
Simulator-internal accesses.
-
Memory Access Breakpoints are preceded by READ,
WRITE, or READWRITE when listed using the
BreakList command.
-
Execution Breakpoint: the specified expression is a simple
address.
Execution Breakpoints halt program execution or execute a
command when the specified code address is reached. Execution
speed is not affected.
The code address specified must be the first byte of an
instruction. If an Execution Breakpoint is set on the second or
third byte of an instruction, then the breakpoint never
triggers.
An Execution Breakpoint can be specified only once for a code
address. Multiple definitions are not allowed.
-
Conditional Breakpoint: the specified expression cannot be
resolved to an address.
Conditional Breakpoints halt program execution or execute a
command when the specified conditional expression is TRUE. The
conditional expression is recalculated after each assembly
instruction. Program execution speed may slow down considerably
depending on the amount of Conditional Breakpoints and the
complexity of the expression.
Conditional Breakpoints are the most flexible type of
breakpoint, because optional conditions can be calculated using
expressions.
Examples
The following breakpoint is valid:
BS WRITE time.sec /* Valid expression */
The following breakpoint is invalid, because adding two values
(timer.sec and i0) does not result in a memory type:
BS WRITE time.sec + i0 /* Invalid expression */
The following example sets an execution breakpoint on the address
of the main function.
BS main
The following example sets an execution breakpoint on the address
of the timer0 function. The breakpoint occurs and the command
"MyRegs()" is executed only after the 10th invocation of
timer0. Program execution continues after the command
executes.
BS timer0,10,"MyRegs()"
The following example sets a conditional breakpoint on the
sindex symbol. When sindex is equal to 8, program
execution halts.
BS sindex == 8
The following example sets a conditional breakpoint on the
save_record array. Program execution halts on the third time
save_record[5].time.sec is greater than 5.
BS save_record[5].time.sec > 5, 3
The following example sets a memory access breakpoint on READ
accesses of the interval.min symbol. Program execution halts
when the min element of the interval structure or union
is 3.
BS READ interval.min == 3
The following example sets a memory access breakpoint on WRITE
accesses to the savefirst symbol. Program execution halts when
savefirst is 5 and the accumulator (acc) is 0x12 after
savefirst is written.
BS WRITE savefirst == 5 && acc == 0x12
Note
-
Breakpoints can be also defined using the Breakpoints dialog.