The memory access triggers allow memory access to both variables and instructions. A memory access trigger if set on an instruction fires when the instruction is fetched from the memory. A memory access trigger if set on a variable fires when the variable is fetched from the memory or when the variable is written back to the memory. When a memory access trigger is set on a variable, trace collection starts from the first access to that variable address.
To collect trace using
Memory at Address A is Accessed:
- 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 2.
- Press the Enter key after the statement, void ContextSwitch(FUNC_TYPE, int); in the source code.
- Type the statement, volatile int a; at the cursor position.
- In the main () function of the source code, before for(;;), type the statement, a = 1;.
- Save and build the project.
- 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 Collect Program Trace option in the Trace Mode Options group.
- Select the Continuously option.
- Select the Collect Trace From Trigger option in the Trace Start/Stop Conditions group.
- Clear the Keep Last Buffer Before Trigger checkbox.
- Select the Memory Access option in the Trigger Selection group.
- Select the Memory at Address A is Accessed option from the Trigger Type drop-down list.
- Click Apply to save the settings.
- Click Debug to debug the application.
- After the application is debugged, right-click in the Variables view, and select the Add Global Variables option from the context menu.
The
Add Globals
dialog box appears.
- Scroll down and select the variable a.
- Click OK.
The
Add Globals
dialog box closes and the variable
a is added in the
Variables
view.
- Right-click the variable a and select Toggle Triggers > Toggle HCS08 Trace Trigger A from the context menu.
The
Toggle HCS08 Trace Trigger
dialog box appears.
- Click OK.
- Click Resume.
The tracing starts when the variable
a is accessed.
- Click Suspend after a while.
- 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 memory access trigger A. The trace data starts collecting from trigger A, that is a=1; onwards.
Figure 1. Trace Data After Setting Memory Access Trigger 
This is how you can collect trace using the
Memory at Address A is Accessed
trigger type.
Note: Similarly, you can set memory access triggers in the Automatically mode. Also, you can set other memory access triggers on variables or instructions, such as Memory at Address A or Address B is Accessed, Memory Inside Range from Address A to Address B is Accessed , Memory Outside Range from Address A to Address B is Accessed , Memory at Address A, Then Memory at Address B are Accessed , Memory access at Address A and Value on Data Bus Match , Memory access at Address A and Value on Data Bus Mismatch , and obtain trace results accordingly.