Home / µVision3 User's Guide
legacy
Program Variables (Symbols)
µVision3 lets you access variables, or symbols, in your target
program by simply typing their name. Variable names, or symbol names,
represent numeric values and addresses. Symbols make the debugging
process easier by allowing you to use the same names in the debugger
as you use in your program.
When you load a target program module the symbol information is
loaded into the debugger. The symbols include local variables
(declared within functions), the function names, and the line number
information. You must enable Options for Target — Output — Debug
Information. Without debug information, µVision3 cannot perform
source-level and symbolic debugging.
Module Names
A module name is the name of an object module that makes up all or
part of a target program. Source-level debugging information as well
as symbolic information is stored in each module.
The module name is derived from the name of the source file. If
the target program consists of a source file named MCOMMAND.C
and the C compiler generates an object file called
MCOMMAND.OBJ, the module name is MCOMMAND.
Symbol Naming Conventions
The following conventions apply to symbols.
-
The case of symbols is ignored: SYMBOL is equivalent to
Symbol.
-
The first character of a symbol name must be: 'A'-'Z', 'a'-'z',
'_', or '?'.
-
Subsequent characters may be: 'A'-'Z', 'a'-'z', '0'-'9', '_',
or '?'.
Notes
-
When using the ternary operator ("?:") in µVision3 with a
symbol that begins with a question mark ("?"), you must insert a
space between the ternary operator and the symbol name. For
example, R5 = R6 ? ?symbol : R7.
Fully-Qualified Symbols
Symbols may be entered using a fully qualified name that includes
the name of the module and name of the function in which the symbol
is defined. A fully qualified symbol name is composed of the
following components:
-
Module Name identifies the module where a symbol is
defined.
-
Line Number identifies the address of the code generated
for a particular line in the module.
-
Function Name identifies the function in a module where
a local symbol is defined.
- Symbol Name identifies the name of the symbol.
This components may combined as shown in the following table:
Symbol Components |
Full Qualified Symbol Name addresses ... |
\ModuleName\LineNumber |
... line number LineNumber in ModuleName. |
\ModuleName\FunctionName |
... FunctionName function in ModuleName. |
\ModuleName\SymbolName |
... global symbol SymbolName in ModuleName. |
\ModuleName\FunctionName\SymbolName |
... local symbol SymbolName in the FunctionName
function in ModuleName. |
Examples of fully qualified symbol names:
Full Qualified Symbol Name |
Identifies ... |
\MEASURE\clear_records\idx |
... local symbol idx in the clear_records
function in the MEASURE module. |
\MEASURE\MAIN\cmdbuf |
... cmdbuf local symbol in the MAIN function in
the MEASURE module. |
\MEASURE\sindx |
... sindex symbol in the MEASURE module. |
\MEASURE\225 |
... line number 225 in the MEASURE module. |
\MCOMMAND\82 |
... line number 82 in the MCOMMAND module. |
\MEASURE\TIMER0 |
... the TIMER0 symbol in the MEASURE module.
This symbol may be a function or a global variable. |
Non-Qualified Symbols
Symbols may be entered using the only name of the variable or
function they reference. These symbols are not fully qualified and
searched in a number of tables until a matching symbol name is found.
This search works as follows:
-
Register Symbols of the CPU: R0 – R15, RL0 – RH7, DPP0 –
DPP3.
-
Local Variables in the Current Function in the target
program. The current function is determined by the value of the
program counter.
-
Static Variables in the Current Module. As with the
current function, the current module is determined by the value of
the program counter. Symbols in the current module represent
variables that were declared in the module but outside a
function.
-
Global or Public Symbols of your target program. SFR
symbols defined by µVision3 are considered to be public symbols and
are also searched.
-
Symbols Created with the µVision3 DEFINE Command. These
symbols are used for debugging and are not a part of the target
program.
-
System Variables that monitor and change debugger
characteristics. They are not a part of the target program. Refer
to System Variables for
more information.
-
CPU Driver Symbols (VTREGs) defined by the CPU driver.
Refer to CPU Pin Registers
(VTREGs) for a description of VTREG symbols.
Notes
-
The search order for symbols changes when creating user or
signal functions. µVision3 first searches the table of symbols
defined in the user or signal function. Then, the above list is
searched. Refer to µVision3 Debug
Functions for more information about user and signal
functions.
-
A literal symbol that is preceded with a back quote character
(') modifies the search order: CPU driver symbols (VTREGs)
are searched instead of CPU register symbols.
Literal Symbols
With the back quote character (') you get a literal symbol name.
Literal symbols must be used to access:
-
a program variable or symbol which is identical with a
predefined Reserved Word. Reserved Words are µVision3
debug commands & options, data type names, CPU register names
and assembler mnemonics.
-
a CPU driver symbol (VTREG) that is identical to program
variable name.
If a literal symbol name is given, µVision3 changes the search
order for non-qualified symbols that is described above. For a
literal symbol CPU Driver Symbols (VTREGs) are searched
instead of CPU Register Symbols.
Examples for using Literal Symbols
If you define a variable named R5 in your program and you
attempt to access it, you will actually access the R5 CPU
register. To access the R5 variable, you must prefix the
variable name with the back quote character.
Accessing the R5 Register |
Accessing the R5 Variable |
>R5 = 121
|
>'R5 = 212
|
If your program contains a function named clock and you
attempt to access the clock VTREG, you will get the address of the
clock function. To access the clock VTREG, you must prefix the
variable name with the back quote character.
Accessing the clock function |
Accessing the clock VTREG |
>clock
0x00000DB2
|
>'clock
20000000
|
Related Knowledgebase Articles