To set triggers on data and memory:
- In the CodeWarrior Projects view, expand the Sources folder of your project.
- 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.
- Open the Debug Configurations dialog box, and select your project in the tree structure.
- Click the Trace and Profile tab, and check the Enable Trace and Profile checkbox.
- Select the Automatically option in the Trace Mode Options group.
- Select Collect Trace Until Trigger in the Trace Start/Stop Conditions group.
- Check the Break on Trigger Hit checkbox.
- Select the Instruction at Address A is Executed option in the Trigger Type drop-down list.
- Click Apply to save the settings.
- Click Debug to debug the application.
- In the Disassembly view, view the address corresponding to the call to f2() before __RESET_WATCHDOG().
Figure 1. Disassembly View - Selecting Function Address 
- Select Window > Show View > Other > Debug > Memory to open the Memory view.
- Click the Add Memory Monitor button in the Memory view to open the Monitor Memory dialog box.
- Enter the memory address in hexadecimal form in the Enter address or expression to monitor text box.
Figure 2. Monitor Memory Dialog Box 
- Click OK.
The memory address appears in the
Memory
view.
- 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 
The
Toggle HCS08 Trace Trigger
dialog box appears.
Figure 4. Toggle HCS08 Trace Trigger Dialog Box 
- Click OK.
- 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 
- Click Resume.
The application stops automatically and trace is collected.
- 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 
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().