This topic explains how to set comparator 1 and comparator 2 as hardware tracepoints for trace collection. You can take any combination of comparators to be used as hardware tracepoints. You simply need to specify the correct corresponding reference value against them.
This topic uses the addresses of the instructions, of
Listing: Source code for trace collection, at which you set start and stop hardware tracepoint. These addresses will be set against comparator 1 and comparator 2 to collect the same trace results that appear on setting hardware tracepoints from the source code.
To set hardware tracepoints using the
Trace and Profile
tab and collect trace on a Kinetis Cortex M4 project:
- Build your 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 the Advanced Settings button.
The
Preferences
dialog box appears.
Figure 1. Preferences Dialog Box 
- In the Trace Start/Stop Control group, check the DWT comparator 1 checkbox in the Start Resource group and the DWT comparator 2 checkbox in the Stop Resource group.
Figure 2. Trace Start/Stop Control Settings 
- In the Comparator 1 tab, specify the following settings: Select the Instruction address match option in the Generate Comparator Match Event on drop-down list. In the Value text box, specify the address of the instruction on which you want to set comparator 1. For example, set the address of the instruction where you set the start hardware tracepoint in Listing: Source code for trace collection.
Figure 3. Setting Comparator 1 
Note: You can view the address of an instruction in the Disassembly view. Open the Disassembly view while the application is running, navigate to the instruction, and take the first address.
- In the Comparator 2 tab, specify the following settings: Select the Instruction address match option in the Generate Comparator Match Event on drop-down list. In the Value text box, specify the address of the instruction on which you want to set comparator 2. For example, set the address of the instruction where you set the stop hardware tracepoint in Listing: Source code for trace collection.
Figure 4. Setting Comparator 2 
- Click OK to close the Preferences dialog box.
- Click Apply to save the settings.
- Click Debug to debug the application.
- Click Resume to resume the program execution.
- Wait for some time to let the application terminate.
- In the Software Analysis view, expand the project name and click the Trace hyperlink.
The
Trace Data
viewer appears displaying the same results as shown in Figure 3 and Figure 4.