How to use the XSCOPE start/stop event type
version
1.0.0
scope
Example.
This code is provided as example code for a user to base their code on.
description
How to use the XSCOPE start/stop event type
boards
Unless otherwise specified, this example runs on the SliceKIT Core Board, but can easily be run on any XMOS device by using a different XN file.
XSCOPE is fully supported on hardware platforms which provide an XMOS link between the target device and the XSYS development connector.
View the document (XSCOPE overview) for further information on tracing data from XMOS applications.
This example provides a simple demonstration of using the XSCOPE start/stop event type for data logging from within an xCORE application. The start/stop event type is used for recording the time taken for between two points in an application. This allows a user to see how long the device has spent in specific code sections for performance analysis and debugging
This example assumes you are familiar with creating a run configuration and enabling the associated XSCOPE options in that run configuration in xTIMEcomposer Studio or using the command line tools.
In order to used XSCOPE the correct header file must be included in the application
#include <xscope.h>
Within a function make a call to xscope_probe() for a specified probe id to signal a toggle in state from start to stop. This allows the time period between these points to be measured.
void function_1(void) { xscope_probe(0); wait(150000); xscope_probe(0); }
Using the XSCOPE constructor which gets called automatically by the XSCOPE system register 4 probes using event type XSCOPE_STARTSTOP which will collect data of type XSCOPE_UINT.
These are used for each of the functions in the code you want to time.
void xscope_user_init(void) { xscope_register(4, XSCOPE_STARTSTOP, "Function 1", XSCOPE_UINT, "Units", XSCOPE_STARTSTOP, "Function 2", XSCOPE_UINT, "Units", XSCOPE_STARTSTOP, "Function 3", XSCOPE_UINT, "Units", XSCOPE_STARTSTOP, "Function 4", XSCOPE_UINT, "Units"); }