2.4 Using the Stopwatch

The stopwatch is useful for simple timing between program halts. Reach this window from Window>Debugging>Stopwatch.

To use the Stopwatch:

  1. Optional: Add breakpoint(s) to your program code.
  2. Select Window>Debugging>Stopwatch to open the window.
  3. Debug Run the program until it halts (breakpoints) or you halt it (Pause). Text in the window will state:
Target halted. Stopwatch cycle count = cycles (time)
  4. Debug Run again until the next halt to see other times.
Figure 2-6. Stopwatch Window with Break Timing

Instruction Cycles

The simulator counts instruction cycles between pausing (halts).

PIC MCUs and dsPIC30F/PIC24F devices use 4 clock cycles per instruction. dsPIC33F/PIC24H devices use 2 clock cycles per instruction.

Clear the stopwatch window contents by clicking the Clear History button.

Processor Frequency

This field, including Frequency units, will be set from File>Project Properties, “Simulator” category, “Oscillator Options” options category.

Window Icons

The stopwatch has the following icons on the left side of the window:

Table 2-3. Stopwatch Icons
Icon Icon Text Description
Properties This option is not available for MPLAB X Simulator.
Reset Stopwatch on Run Default option - always set.
No Reset Stopwatch on Run This option is not available for MPLAB X Simulator.
Clear History Clear the stopwatch window.
Clear Stopwatch Reset the stopwatch value to zero.