To set the tracepoints in the editor area for the HCS08 target:
- 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 below.
Listing: Source Code 1
#include <hidef.h> /* for EnableInterrupts macro */
#include "derivative.h" /* include peripheral declarations */
volatile int a, b;
void f() {}
void f1()
{
b=1;
b=2;
b=3;
}
void f2()
{
a=1;
a=2;
a=3;
}
void main(void) {
EnableInterrupts;
/* include your code here */
f();
f();
f();
for(;;) {
__RESET_WATCHDOG();/* feeds the dog */
f1();
f2();
} /* loop forever */
/* please make sure that you never leave main */
}
- 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.
- Click Apply and close the Debug Configurations dialog box.
- In the editor area, right-click the marker bar corresponding to the statement, f1();.
- Select Trace Triggers > Toggle Trace Trigger A from the context menu. The same option is also used to remove trigger A from the marker bar.
- Right-click the marker bar corresponding to the statement, f2();.
- Select the Trace Triggers > Toggle Trace Trigger B option from the context menu. The same option is also used to remove trigger B from the marker bar.
Note: It is recommended to set both triggers in the same function so that the trace data that is collected is meaningful.
Figure 1. Trigger A and Trigger B Set in the Editor Area 
Note: Do not set tracepoints on the statements containing only comments, brackets, and variable declaration with no value. If tracepoints are set on invalid lines, they are automatically disabled when the application is debugged.
- Open the Debug Configurations dialog box, and select your project in the tree structure.
- Click the Trace and Profile tab.
- 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.
- Select the Instruction at Address A, Then Instruction at Address B are Executed option from the Trigger Type drop-down list.
- Clear the Keep Last Buffer Before Trigger checkbox.
- Ensure that the Instruction Execute option is selected in the Trigger Selection group.
- Click Apply to save the settings.
- Click Debug to debug the application.
- Collect the trace data following the steps explained in the topic Collecting Data.
- Open the Trace Data viewer following the steps explained in the topic Viewing Data to view the collected data.
The figure below shows the data files that are generated by the application in which the data has been collected after setting the tracepoints in the source code.
In the figure, the trace data shows that the
main() function calls the
f2() function. Because you selected the
Instruction at Address A, Then Instruction at Address B are Executed
mode, both A and B trigger trace. Also, trace starts collecting from trigger B after trigger A has occurred.
Figure 2. Trace Data After Setting From Trigger in Continuously Mode 
The figure below shows the data file generated by the application in which the data has been collected before setting the tracepoints in the source code. In this data file, the main
() function is called and it further calls the
f(),
f1(), and
f2() functions. The
f1() and
f2() functions are called in a loop.
Note that the data file generated with tracepoints, as shown in the above figure, is different from the data file generated without the tracepoints, as shown in the figure below.
Note: The trace data only contains destinations that cannot be obtained from disassembly. For example, return addresses, which are kept on stack, or conditional destinations, such as jump address and next address.
Figure 3. Trace Data Before Setting Tracepoints 
Note: Hover mouse pointer over a tracepoint icon in the marker bar to view the attributes of the tracepoint on the corresponding line of code.
The graph in figure below shows the timeline of the trace data which is collected after setting the tracepoints. In this graph, you can see that the
main() function calls the
f1() and
f2() functions and not the
f() function. To have a clearer view of the graph, you can zoom-in or zoom-out in the graph by scrolling the mouse wheel up or down.
Figure 4. Graph Displaying Timeline of Trace Data 
Similarly, you can collect the trace data with the
Keep Last Buffer Before Trigger
checkbox checked in the
Continuously
mode. The trace collection remains same except that the trace buffer is overwritten until the triggers are hit and only the last part of the buffer trace is visible in the
Trace Data
viewer.