User manual

MPLAB
®
REAL ICE
In-Circuit Emulator User’s Guide
DS51616B-page 50 © 2008 Microchip Technology Inc.
4.13.2 Tracing a Line of Code
To trace a line of code:
1. Remove the log macro line from code, i.e., highlight it and hit <Delete>.
2. Highlight or click on the following line of code:
counter++; //increment counter
Right click to select “Insert C Line Trace” from the pop-up menu. This causes the
following macro line to be inserted above the selected line:
__TRACE(id);
where id is a line trace number auto-generated during the build.
3. Rebuild the project (Project>Build All
).
4. After rebuilding, a Warning dialog will ask, “File has been modified. Do you want
to reload?” (if you have not already disabled this dialog.) Click Yes. When you
examine your code, you will find that the log id has been replaced with a unique
number.
5. Reprogram the device (Debugger>Program
).
6. Run the program until it halts at the breakpoint. Repeat this three times.
7. Select View>Trace
to view the trace data (Section 11.3.11 Trace Window”) or
right click and in the Trace window and select “Reload”. You should see address
values logged in this window. To see the related code in the lower portion of the
window, you may need to click on a logged value in the upper portion of the win-
dow.
FIGURE 4-21: VIEW TRACE WINDOW – TRACE LINE
4.13.3 Setting the Size of the Trace Buffer
In this tutorial, a breakpoint was used to ensure that the trace buffer did not overflow
with values from an executing program. A “for” instead of “while” loop could be used as
well to control the number of trace samples.
To set the size of the trace buffer:
1. Select Debugger>Settings
, Trace tab.
2. Enter a value for the trace buffer, not to exceed the maximum specified on this
tab.