Trace and Profiling

Depending on the device you have selected for your project, you may be able to use trace, PC sampling/profiling or other data collection features when debugging. Enable and set up these features as specified in the following sections.

8-Bit and 16-Bit Devices

Options available on this page depend on the trace/profiling features of the project device.

Table 1. Trace/Profiling Option Category
Data Collection Selection Enable/Disable data collection.
  • Off - Do not collect target data.
  • User Instrumented Trace
  • PC Sampling
  • Power Monitor (Target Power Sampling)
Data File Path and Name Enter or change the path and/or name of the file used to store data.
  • Enter file name (path will be relative to project) – Recommended
  • Enter a path and file name (path will be absolute)
  • Browse (...) to a file, select “Absolute”, select the file, and click Save (path will be absolute)
Note: Do not select “Relative” when browsing to a file or MPLAB X IDE will not be able to find the file. When you run, you will receive a warning message that the path does not exist.
Data File Maximum Size (bytes) Set the maximum size of the data file.

Target power sampling will take 12 bytes or 18 bytes (with PC data) per sample.

The file size may be adjusted down to be a multiple of one of those byte sizes depending upon the trace type selected. Other trace data types may use record byte sizes that are different from those described above.

Data Buffer Maximum Size (bytes) Set the size of the data buffer, up to 54600 bytes (on board the emulator unit.)

For trace/sampling data that is buffered in memory while the target is running, individual trace or sample entry sizes vary depending upon the trace/sample type and the device and tool being used. It is normally good to make this buffer as large as possible.

For example, the enhanced PIC16 with instruction trace uses 1 to 3 bytes for each in-memory entry. Each of those will generate a 13-byte ICE4 instruction trace entry as well. Each such in-memory record will normally be converted to a trace data file entry line, as detailed in the data file size description (refer to the data file size description for trace/sampling file entry sizes).

Stall CPU When Trace Buffer is Full Stop execution when the trace buffer is full. Set the buffer size in the option described above.
User Instrumented Trace Items
Disable Trace Macros Check to temporarily disable trace macros or uncheck to enable trace macros.

To disable trace, remove all macros and select “Off” under “Data Collection Selection”.

Communications Medium Select the trace medium, if available, from the following (device-dependent): Native, I/O Port, SPI.
I/O Port Selection Specify the device port to be used for I/O port trace.

The available combinations for the selected device will be listed.

SPI Selection Specify the device SPI pins to be used for SPI trace. The available pins for the selected device will be listed.
PC Sampling Items
Timer Selection (Not Used by Application Code) Select a device timer to use to count PC samples.
Note: You will no longer be able to use this timer in your application, it will be dedicated to PC sampling.
Note: You may select only one timer; you cannot combine two timers to get a 32-bit timer. Using one timer of a 32-bit-timer pair will prohibit that pair from operating as a 32-bit timer.
Timer Interrupt Priority Select an interrupt priority for the timer.
Note: Select a priority that is higher than other priorities you have set in your application. If you do not, the other priorities will preempt the sampling priority and you will not capture these samples.
Timer Interval Enter a sampling interval.

This must be integer values (1, 2, 3, and so forth).

If you are not capturing data, you may be missing samples (given your current interval). Try adjusting the unit selection and interval, for example, if you had 1 millisecond, try 990 microseconds.

Timer Interval Units Select a sampling interval unit:
  • microseconds
  • milliseconds
  • seconds
  • instruction cycles

32-Bit Devices

Options available on this page depend on the trace/profiling features of the project device.

Table 2. Trace/Profiling Option Category
Data Collection Selection Enable/Disable data collection.
  • Off - Do not collect target data.
  • Instruction Trace/Profiling
  • User Instrumented Trace
  • Power Monitor (Target Power Sampling)
Data File Path and Name Enter or change the path and/or name of the file used to store data.
  • Enter file name (path will be relative to project) – Recommended
  • Enter a path and file name (path will be absolute)
  • Browse (...) to a file, select “Absolute”, select the file, and click Save (path will be absolute)
Note: Do not select “Relative” when browsing to a file or MPLAB X IDE will not be able to find the file. When you run, you will receive a warning message that the path does not exist.
Data File Maximum Size (bytes) Set the maximum size of the data file.

Each line of instruction trace data in a trace data file requires 13 bytes when using the emulator.

Target power sampling will take 12 bytes or 18 bytes (with PC data) per sample.

The file size may be adjusted down to be a multiple of one of those byte sizes depending upon the trace type selected. Other trace data types may use record byte sizes different from those described above.

Data Buffer Maximum Size (bytes) Set the size of the data buffer, up to 54600 bytes (on board the emulator unit.)

For trace/sampling data that is buffered in memory while the target is running, individual trace or sample entry sizes vary depending on the trace/sample type and the device and tool being used. It is normally good to make this buffer as large as possible.

For example, PIC32 instruction trace takes 8 bytes per “frame” which can produce over 50 13-byte ICE 4 instruction trace entries in a trace file.

User Instrumented Trace Items
Disable Trace Macros Check to temporarily disable trace macros or uncheck to enable trace macros.

To disable trace, remove all macros and select “Off” under “Data Collection Selection”.

Communications Medium Select the trace medium, if available, from the following (device-dependent): Native