From Variables View

To set trigger C from the Variables view:

  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 of the main.c file with the source code shown in Listing: Source code for trace collection.
  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. Select the Continuous option from Select Trace Mode .
  7. Select the Trace from Trigger C Onward option from the Trace Start/Stop Conditions group.
  8. Click Apply to save the settings.
  9. Click Debug to debug the application.
  10. In the Variables view, right-click a cell in the Name column.
  11. Select the Add Global Variables option from the context menu. The Add Globals dialog box appears.
  12. Select all the variables with Shift key pressed and click OK . All the variables of the program get added to the Variables view.
  13. Right-click the variable a, in the Name column of the Variables view.
  14. Select Toggle Triggers > Set CFv1 Trace Trigger C option from the context menu.

    The Set Trigger Properties dialog box appears.

  15. Select the Read/Write option from the Access drop-down list.
    Figure 1. Set Trigger Properties Dialog Box
    Set Trigger Properties Dialog Box
  16. Click OK.
  17. Select Window > Show View > Other > Analysis > Analysispoints to open the Analysispoints view. The Analysis points view displays the trigger C set on the variable address.
    Figure 2. Analysispoints View
    Analysispoints View
  18. Click Resume to collect trace.
  19. After a short while, click Suspend to stop the target application.
  20. Open the Trace Data viewer following the steps explained in the topic Viewing Data to view the trace results.

The figure below shows the data files generated by the application after setting trigger C in the Continuous mode on the variable address.

Figure 3. Trace Data After Setting Trace from Trigger C in Continuous Mode
Trace Data After Setting Trace from Trigger C in Continuous Mode

The variable a is accessed first time in the f2() function. Therefore, after setting trigger C on the address of a, the trace data starts collecting from f2(). The trace data continues till you suspend the application.

Note: When trigger C is hit, trace starts from the instruction where the variable on which trigger C has been set is first accessed. However, trace misses the first few instructions due to a delay from the hardware. Therefore, the Trace Data viewer does not display the first instruction of the variable. Instead, it displays the trace data starting from the instructions that are executed after the first instruction of the variable.