How to use the XSCOPE discrete 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 discrete 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 discrete event type for data logging from within an XMOS application. The discrete event type is used for recording the value of a captured variable for a length of time before that value is changed. This lets you see the level of a particular variable over time and the points at which it has been changed by the application.
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>
Declare a variable you are going to trace as an XSCOPE discrete event type
unsigned int memory_used = 0;
The xscope_probe_data() function is used to send the contents of user variable memory_used to XSCOPE probe id 0 for logging
xscope_probe_data(0, memory_used);
Using the XSCOPE constructor which gets called automatically by the XSCOPE system register 1 probe using event type XSCOPE_DISCRETE which will collect data of type XSCOPE_UINT
void xscope_user_init(void) { xscope_register(1, XSCOPE_DISCRETE, "Memory Allocated", XSCOPE_UINT, "Bytes"); }