Setting Up Instrumented Trace in MPLAB® X IDE
To set up MPLAB® X IDE to use trace for the MPLAB® REAL ICE™ In-Circuit Emulator:
- Right-click on the project name and select Properties. In the Project Properties dialog box, click on Real ICE under Categories.
- Under Option categories, select Clock. For data capture and trace, the emulator needs to know the instruction cycle speed.
- Under Option categories, select Trace and Profiling.
- Under Data Collection Selection, choose User Instrumented Trace.
- Under Communications Medium, choose either Native, I/O PORT, or SPI trace.
- Set up any other trace-related options. (See Trace and Profiling Options.)
- Click OK.
Next, enter trace macros into your application code.
- To record a PC location, click on or highlight a line of code and then right-click to select Insert Language Line Trace from the pop-up menu, where Language can be either C or ASM. 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. For more information, see More on Trace/Log ID Numbers.
Note: Inserting a macro into code may modify the logic flow of the program. Check that braces are present wherever they are necessary.
- The recording of a variable value is performed similarly. First, highlight the variable name or expression. 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 that was auto-generated during the build and the selected variable is the highlighted variable. For more information, see More on Trace/Log ID Numbers.
- To remove a tracepoint, simply highlight and then delete the Trace/Log macro.