Datasheet
Specific Debug Functions: 8- and 16-Bit Devices
2013 Microchip Technology Inc. DS52085A-page 59
• The recording of a variable value is performed much in the same way. First high-
light the variable name or expression and then right click to select “Log Selected
Language Value” from the pop-up menu, where Language can be either C or
ASM. This causes the following macro line to be inserted above the line
containing the variable:
__LOG(id,selected variable);
where id is a log number auto-generated during build and selected variable
is the highlighted variable. For more information, see Section 6.3.9 “More on
Trace/Log ID Numbers”.
• To remove a trace point, simply highlight and then delete the Trace/Log macro.
6.3.5 Running Trace
1. Debug Run (Debug>Debug Project) your application.
2. Pause the application.
3. View the trace data in the Trace window (Window>Debugging>Trace
). For each
__TRACE macro, the line of code following the macro will appear in the trace win-
dow each time it is passed. For each __LOG macro, the selected variable in the
line of code following the macro will appear in the trace window each time it is
passed.
Repeat these steps each time you change a trace point.
6.3.6 Tracing Tips
When using __TRACE and __LOG macros in your code, consider the following:
• Focus on one area of an application and place __TRACE and __LOG macros so
that they form a “flow” in the Trace window. That way, you can follow the execution
flow and debug the application based on missing/incorrect trace points or an
abrupt end to the trace flow.
•Use __TRACE and __LOG macros with conditional statements in your code to aid
in debugging. Example: When a variable reaches a certain value, start logging it.
If(var > 5)
{
__LOG(ID, var)
}
• Leave __TRACE and __LOG macros in your code for future debugging, if this is
allowable. (For Project Properties dialog, REAL ICE Category, Trace Options Cat-
egory page, select “Disable Trace Macros“.)
Note: To trace multiple lines of code or variables, you must place a macro
before each line/variable that you wish to trace.