2.1.6.6.1 Data Polling Example

An example on how to use Program Counter sampling for power consumption analysis can be found in Program Counter Polling. The same Mass Storage Class example used in this section is also suited as an example on how to use the data polling and control of data variables features. A SAM L21 Xplained Pro board is connected to a host computer both through Target USB and Debug USB connectors on the kit. The ATSAML21 target device is running the USB Device MSC Example from ASF for SAM L21 Xplained Pro.

For more information on the hardware setup and target application code used in this example, see Data Polling Example Code.

Although this example makes use of the Graph and Dashboard modules the principles are the same for using the Code Profiling interface with the other modules in the Data Visualizer.

First, a graph will be set up to monitor variables in the target application.

Todo:
  • Enable the Code Profiling interface by deselecting the check box for the Code Profiling interface in the DGI Control Panel
Todo:
  • Open the Code Profiling Configuration window by pushing the Gear button
Todo:
  • Click the Add Memory Location button for each memory location to be added
  • Fill in the address and format of each location
Todo:
  • Open the Configuration panel in Data Visualizer
  • Add a graph by double-clicking the Graph module

A new Graph element will open with one y axis configured. However, there are two unrelated variables to monitor, therefore, two axes are needed.

Todo:
  • Click the Add axis button to add an additional axis

There are now sources (variables) and sinks (axes), to be connected together.

Todo: Drag each of the source plugs on the Code Profiling interface into the New plot (sink) jack of each axis.
Todo: In Atmel Studio click Continue (F5) to resume execution.
Tip: A USB device in the HALT state no longer responds to Windows events, and may be disconnected from the bus if held in this state for too long. To remedy this simply reset execution in Atmel Studio.
Look at the output in the graph in Data Visualizer. Format the disk and watch how the write cycles counter increments. Both values are plotted on independent axes, so they can be scaled accordingly. The output should look something like this:

The following part of this example shows how to use a dashboard to interact with the target application. For more information on the required code changes in the target application, see Application Interaction using Dashboard Controls.

Todo:
  • Open Data Visualizer
  • Connect
  • Add the location of the frame_comparator in the Code Profiling Configuration window
A Data Visualizer dashboard can now be made with controls which manipulate the value of this variable.
Todo:
  • Open the configuration panel
  • Add a new I/O Dashboard component by double-clicking the I/O Dashboard module

A slider control can now be added to the dashboard.

Todo:
  • Select the Edit checkbox
  • Open the Elements tab
  • Drag a Slider element onto the dashboard
A slider control needs to have some configuration parameters.
Todo: Select the slider element and set its properties:
  • Maximum = 500
  • Minimum = 100
A segment display control can now be added to the dashboard.
Todo:
  • Select the Edit checkbox
  • Open the Elements tab
  • Drag a Segment Display element onto the dashboard
A segment display control needs to have some configuration parameters.
Todo: Select the segment display element and set its properties:
  • Segment Count = 3
The slider control can now be used as a source which can be connected to any relevant sink in Data Visualizer. The segment display can similarly be used as a sink to connect any relevant source to.

The Code Profiling data polling interface provides both a source of data and a sink of data. The slider can now be connected to the sink and the segment display to the source.

Todo:
  • Deselect the Edit checkbox
  • Select the Show Endpoints checkbox
  • Connect sources to sinks by dragging each source plug and drop it on a sink
Now that the connections have been made in Data Visualizer, the system can be put into a running state and interaction with the variable can be made through the GUI.
Todo:
  • Deselect the Show Endpoints checkbox
  • Start Data Visualizer
  • Resume execution in Atmel Studio (F5)
The slider is now in control of the frame_comparator variable in the application code. Drag the slider, and notice that the LED blink frequency changes. Any change in the slider position will be sent to the target device through the debug interface, and a new value stored in the variable. At the same time, the value is also read back from the target and displayed on the segment display.