LOOP1 Mode

The LOOP1 Mode feature when selected writes a register to allow the hardware to use the C comparator and not store duplicate addresses in trace. In LOOP1 capture mode, the addresses for instructions executed repeatedly, for example, loops with no change of flow instructions and recursive calls, are stored and showed in trace only once.

The hardware uses comparator C available only on variants with DBGv3, which cannot be used for trace, to store the last FIFO address. Only comparators A and B can be used for trace on all variants. However, in LOOP1 capture mode, comparator C is not available for use as a normal hardware breakpoint, and is managed by logic in the DBG module to track the address of the most recent change-of-flow event that was captured into the FIFO buffer.

Note: The LOOP1 Mode option is visible only for the debug version 3 (DbgVer 3) targets, that is HCS08 target with three comparators. For any other targets with two comparators, this option is not visible.

To set a trigger in LOOP1 Mode:

  1. In the CodeWarrior Projects view, select the Sources folder of your project.
  2. Double-click the source file, for example, main.c to display its contents in the editor area. Replace the source code in the main.c file with the source code shown in Listing: Source code 4
  3. Save and build the project.
  4. Open the Debug Configurations dialog box, and select your project in the tree structure.
  5. Click the Trace and Profile tab, and check the Enable Trace and Profile checkbox.
  6. Click Apply to save the settings, and close the Debug Configurations dialog box.
  7. In the editor area, right-click the marker bar corresponding to the statement, Recursive(3); in the main() function.
  8. Select Trace Triggers > Toggle Trace Trigger A from the context menu.
  9. Open the Debug Configurations dialog box, and click the Trace and Profile tab.
  10. Select the Collect Program Trace option in the Trace Mode Options group.
  11. Select the Automatically option.
  12. Select the LOOP1 Mode check box.
  13. Select Collect Trace From Trigger in the Trace Start/Stop Conditions group.
  14. Check the Break on FIFO Full checkbox.
  15. Select Instruction at Address A is Executed from the Trigger Type drop-down list.
  16. Click Apply to save the settings.
  17. Click Debug to debug the application.
  18. Click Resume.

    The application stops automatically and collects data in data file.

  19. Open the Trace Data viewer following the steps explained in the Viewing Data topic to see the trace results. The following figures show the data files generated by the application after setting trigger A in the LOOP1 Mode.
    Figure 1. Trace Data After Setting Trigger A in LOOP1 Mode - Automatically
    Trace Data After Setting Trigger A in LOOP1 Mode - Automatically
    Figure 2. Timeline Data After Setting Trigger A in LOOP1 Mode - Automatically
    Timeline Data After Setting Trigger A in LOOP1 Mode - Automatically

The trace data that is collected contains only two calls to Recursive(int n). This is because the three identical PCs in trace for if (n <= 0) is ignored by the hardware and appears only once in LOOP1 mode.

In the normal mode, the hardware would have stored the identical addresses one after another. The figure below shows the trace and timeline data that is collected when LOOP1 Mode option is disabled. Make sure that you clear the LOOP1 Mode checkbox in the Trace and Profile tab, keep the remaining settings same and then collect trace.

In the normal mode, the trace data contains four calls to Recursive(int n) with arguments 3, 2, 1, 0, and three times branch for if (n <= 0), that is three identical PCs in trace. Fourth address of the conditional assembly instruction for if (n <= 0) is not in the trace because that branch is not taken anymore and the last recursive call exits with return 0.

With the LOOP1 Mode option enabled, the hardware skips the identical addresses and keeps only one address instead of three; therefore, the trace data contains only two calls to Recursive(int n).

Figure 3. Trace Data After Setting Trigger A in Normal Mode - Automatically
Trace Data After Setting Trigger A in Normal Mode - Automatically