How to use the XSCOPE state machine event type
version
1.1.0
scope
Example.
This code is provided as example code for a user to base their code on.
description
How to use the XSCOPE state machine 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 state machine event type for data logging from within an xCORE application. The state machine event type is used for recording the value of a variables associated with state change within an application. This allows a user to see how long the device has spent in specific states for timing and debugging purposes.
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 state machine event type
unsigned int current_state = 1;
The xscope_probe_data() function is used to send the contents of user variable current_state to XSCOPE probe id 0 for logging
xscope_probe_data(0, current_state);
Using the XSCOPE constructor which gets called automatically by the XSCOPE system register 1 probe using event type XSCOPE_STATEMACHINE which will collect data of type XSCOPE_UINT
void xscope_user_init(void) { xscope_register(1, XSCOPE_STATEMACHINE, "State Transitions", XSCOPE_UINT, "State"); }