On Data and Memory

To set triggers on data and memory:

  1. In the CodeWarrior Projects view, expand 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 3.
  3. Open the Debug Configurations dialog box, and select your project in the tree structure.
  4. Click the Trace and Profile tab, and check the Enable Trace and Profile checkbox.
  5. Select the Automatically option in the Trace Mode Options group.
  6. Select Collect Trace Until Trigger in the Trace Start/Stop Conditions group.
  7. Check the Break on Trigger Hit checkbox.
  8. Select the Instruction at Address A is Executed option in the Trigger Type drop-down list.
  9. Click Apply to save the settings.
  10. Click Debug to debug the application.
  11. In the Disassembly view, view the address corresponding to the call to f2() before __RESET_WATCHDOG().
    Figure 1. Disassembly View - Selecting Function Address
    Disassembly View - Selecting Function Address
  12. Select Window > Show View > Other > Debug > Memory to open the Memory view.
  13. Click the Add Memory Monitor button in the Memory view to open the Monitor Memory dialog box.
  14. Enter the memory address in hexadecimal form in the Enter address or expression to monitor text box.
    Figure 2. Monitor Memory Dialog Box
    Monitor Memory Dialog Box
  15. Click OK.

    The memory address appears in the Memory view.

  16. Right-click the cell containing the memory address and select Toggle Triggers > Toggle HCS08 Trace Trigger A option from the context menu.
    Figure 3. Memory View
    Memory View

    The Toggle HCS08 Trace Trigger dialog box appears.

    Figure 4. Toggle HCS08 Trace Trigger Dialog Box
    Toggle HCS08 Trace Trigger Dialog Box
  17. Click OK.
  18. Select Window > Show View > Other > Analysis > Analysispoints to open the Analysispoints view.

    The Analysispoints view displays the trigger that you set on the memory address.

    Figure 5. Analysispoints View
    Analysispoints View
  19. Click Resume.

    The application stops automatically and trace is collected.

  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 A in the Automatically mode on memory.

Figure 6. Trace Data After Setting Until Trigger in Automatically Mode
Trace Data After Setting Until Trigger in Automatically Mode

Because you set the Until trigger at the memory address of f2(), the trace data is collected and the trace buffer is overwritten till the trigger is hit. Therefore, only the last part of the trace buffer is collected before the trigger, and the application stops at the memory address of f2().