PC Sampling: 8- and 16-Bit MCUs Only
For PC sampling, a device timer is set up to take samples of program execution and display the results in the PC profiling window.
Requirements
Currently, to use PC sampling your project must be set up for:
- a supported device:
- PIC18F with data capture – To find out if your device has data capture, please see Hardware Tool Debug Features by Device.
- PIC24F, PIC24EP
- dsPIC33FJ, dsPIC33E
- Note: PIC16F1 devices are NOT supported
- an MPLAB® XC8 or MPLAB XC16 C Compiler version 1.10 or above
Clock Setup
To set up the clock:
- Open the Project properties window (File > Project Properties).
- Click on REAL ICE™ under Categories and select Clock from the Options Categories drop-down box. Ensure this value matches the actual target speed (i.e., as set by the Configuration bits in the code).
- Click Apply.
Sampling Setup
To set up sampling:
- Click on REAL ICE under Categories and select Trace and Profiling from the Options Categories drop-down box.
- Under Data Collection Selection, select PC Sampling.
- Set up your data file and timer in this window. For reference, see Trace and Profiling Options.
Note: Ensure the timer you select is not used in your program. - Click OK.
Figure 1: PC Sampling – Selection and Setup
Operation
To generate data:
- Select Window > Debugging > PC Profiling. This will open the PC Profiling window.
- Run your code and then halt.
- View the sampling data in the window. Data is only displayed on halt.
- Right-click in the window to pop up a menu to either clear the data or reload the data.
You may also display this data in the Code Profiling plugin, available for purchase at
MicrochipDirect.com
Figure 2: PC Sampling – PC Profiling Window