8.1 Adding X2Cscope Support to a Project

To use X2Cscope with MPLAB Data Visualizer, your firmware project must include the X2Cscope library and make periodic calls to its API functions.

Prerequisites

  • X2Cscope firmware library for your target MCU family.
  • A free UART peripheral for communication.
  • A timer or periodic interrupt for sampling.

Adding X2Cscope Support

For information about how to create a code project for X2Cscope, see: x2cscope.github.io/docs/firmware/X2CscopeFirmware.html.

The screenshots in this section are based on this code example for dsPIC33CK: mplab-discover.microchip.com/com.microchip.ide.project/com.microchip.mplabx.project.dspic33ck-lvmc-x2cscope-blinky

There are 3 main interfaces that must be integrated into your application.

X2Cscope_init(): Must be called before using other X2Cscope interfaces. When using code configurator, like MCC or Harmony, this will be done automatically. The X2Cscope initialize routine connects the serial peripheral interfaces, initializes LNET protocol, buffers and functions.

X2Cscope_communicate(): Handles the communication with the client on the PC side. This function is not very time critical. This can be executed in a low level task in an RTOS environment, or in the IDLE loop with OS free application. This must be done manually as it highly depends on the final application implementation.

X2Cscope_update(): This is the sample point of the scope, therefore this must be called with the same fixed periodicity as selected in the X2Cscope interface on the PC side. Other wise the time domain will not match in the scope view. If you select a variable for the scope channel on the PC side, then this function will start to stream the values of the selected variables to a reserved RAM buffer. Once the buffer is full the buffer content is transferred to the PC.

Building the Project

Build your project to generate the ELF file. The ELF file contains the symbol information that MPLAB Data Visualizer uses to identify variables in your firmware.