This option captures the data involved in a read and/or write access to the address specified by trigger B, such as the address of a particular control register or program variable. To set trigger B in the Collect Data Trace
mode:
- 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 4
#include <hidef.h> /* for EnableInterrupts macro */
#include "derivative.h" /* include peripheral declarations */
#define MAX_IT 2
typedef int(*FUNC_TYPE)(int);
void entry();
void InterruptTest();
void ContextSwitch(FUNC_TYPE, int);
int PerformanceWork (int);
void Performance1(void);
int Recursive(int);
volatile char iteration = 0;
void Launch(FUNC_TYPE f, int arg)
{
f(arg);
}
void InterruptTest()
{}
void entry()
{
InterruptTest();
Launch(PerformanceWork, iteration++);
Launch(PerformanceWork, iteration++);
if (iteration >= 254) iteration = 0;
}
int PerformanceWork (int iteration)
{
int ret = 0;
if (iteration & 1)
{
Performance1();
ret = 1;
}
else
{
Recursive(3);
ret = 2;
}
return ret;
}
void Performance1(void)
{}
int Recursive(int n)
{
/* Recursively calculates 0 + 1 + 2 + ... + n */
if (n <= 0) /* breakpoint here */
{
return 0;
}
else
{
return (n + Recursive(n-1));
}
}
void main(void)
{
EnableInterrupts; /* enable interrupts */
/* include your code here */
Performance1();
Recursive(3);
Performance1();
for(;;)
{
entry();
__RESET_WATCHDOG(); /* feeds the dog */
} /* 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.
- Select the Collect Data Trace option in the Trace Mode Options group.
- Select Collect Trace From Trigger in the Trace Start/Stop Conditions group.
- Check the Break on FIFO Full checkbox.
- Select Capture Read/Write Values at Address B from the Trigger Type drop-down list.
- Click Apply to save the settings.
- Click Debug to debug the application.
- In the Debug window, right-click in the Name column of the Variables view.
- Select the Add Global Variables option from the context menu.
The Add Globals
dialog box appears.
- Select iteration from the list of available variables.
- Click OK.
The entry for the iteration variable gets added to the Variables
view.
- Right-click the variable iteration and select Toggle Triggers > Toggle HCS08 Trace Trigger B from the context menu.
The Toggle HCS08 Trace Trigger B
dialog box appears.
- Click OK.
- Select Window > Show View > Other > Analysis > Analysispoints to open the Analysispoints view.
The Analysispoints
view displays trigger B that you set on the iteration variable.
Figure 1. Analysispoints View 
- Click Resume.
The application captures accesses to the variable (iteration) address on which you
set trigger B, and stops automatically when buffer gets full.
- Open the Trace Data viewer following the steps explained in the Viewing Data topic to view the trace results. The figure below shows the data files generated by the application after setting trigger B in the Collect Data Trace mode. The trace data that is collected contains values of iteration from 0 to 3.
Figure 2. Trace Collected at Address B 
- Click Resume again.
The application captures more data and stops automatically.
- Open the Trace Data viewer and see new data being appended to the old data.
Figure 3. Trace Data Viewer - New Data Appended 
This is how you set trigger B in the Collect Data Trace
mode and collect trace using the Capture Read/Write Values at Address B
trigger type.
Note: In the Collect Data Trace mode, if you perform target stepping instead of full-run, the collected trace will contain mixed data and program trace. This happens because CodeWarrior changes the trigger mode and FIFO shifts storage condition when target stepping is performed. In target stepping, the processor executes one step each time you press the F6 key (Step Over) and then returns to the suspended (halt) state.