How to use XSCOPE to capture floating point data
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 XSCOPE to capture floating point data
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 continuous event type for data logging from within an xCORE application. The continuous event type is used for recording the value of a variables within an application. The data type captured by the XSCOPE probe can be specified by the user and in this case we look at capturing a floating point value.
This example assumes you are familiar with creating a run configuration and enabling the associated XSCOPE options in that run configuration in the 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>
Using the XSCOPE constructor which gets called automatically by the XSCOPE system register 10 probes using event type XSCOPE_CONTINUOUS which will collect data of type XSCOPE_FLOAT. This are used to capture floating point values from the C math library function sin()
void xscope_user_init(void) { xscope_register(10, XSCOPE_CONTINUOUS, "Sin 1", XSCOPE_FLOAT, "Value", XSCOPE_CONTINUOUS, "Sin 2", XSCOPE_FLOAT, "Value", XSCOPE_CONTINUOUS, "Sin 3", XSCOPE_FLOAT, "Value", XSCOPE_CONTINUOUS, "Sin 4", XSCOPE_FLOAT, "Value", XSCOPE_CONTINUOUS, "Sin 5", XSCOPE_FLOAT, "Value", XSCOPE_CONTINUOUS, "Sin 6", XSCOPE_FLOAT, "Value", XSCOPE_CONTINUOUS, "Sin 7", XSCOPE_FLOAT, "Value", XSCOPE_CONTINUOUS, "Sin 8", XSCOPE_FLOAT, "Value", XSCOPE_CONTINUOUS, "Sin 9", XSCOPE_FLOAT, "Value", XSCOPE_CONTINUOUS, "Sin 10", XSCOPE_FLOAT, "Value"); }
The xscope_probe_data() function is used to send the contents of user variable value to XSCOPE probe id 0 for logging. The floating point type is recorded for correct display when the data is processed on the host machine. In the example data is send to registered probes 0 - 9.
xscope_probe_data(0, value * 100);