By Adam Taylor

In my last blog, I showed you how to use Micrium’s μC/Probe to debug Zynq-based embedded systems in real time without impacting target operation. The example I presented last time demonstrated the basics of how you can use μC/Probe to monitor variables in target memory. While this capability is very useful, μC/Probe has advanced debugging features that can aid us even further to debug our design and provides us with a real-time user interface that lets us control and monitor internal system variables using a variety of graphical interface components.

I want to explore some of these advanced features in this blog including:

Modifying global variables on the target processor during run time.

Implementing an eight-channel oscilloscope, allowing us to monitor multiple variables at run time.

We need to add some simple code to the target to implement the oscilloscope. We do not need to add code if we only wish to modify variables at run time.

To create a more in-depth example, I am going to use the XADC to receive an external signal on the Vp/Vn inputs and then output a copy of the received signal using a Pmod DA4 DAC. The amplitude of the signal output by the Pmod DA4 will be controlled by a software variable which in turn will be controlled using μC/Probe.

To further demonstrate the μC/Probe’s interactive capabilities with GPIO, I have configured the eight LEDs and four DIP switches on the MicroZed IO carrier Card (IOCC) in a manner that will ease interfacing with μC/Probe.

To create this blog’s example in the Vivado design, I instantiated an XADC wizard, routed 12 Zynq PS GPIO signals to the EMIO, and enabled SPI 0 in the Zynq PS. I routed the SPI 0 signals over EMIO as well. I then connected EMIO SPI outputs to a Pmod bridge, as the Pmod DA4 has no defined driver.

Vivado Block Design for the Advanced μC/Probe Example

With the Vivado design built and exported to SDK, I needed to create a software application to perform the following:

Initialize the Zynq SoC’s XADC, GPIO, SPI, and Interrupt controllers

Configure the XADC to receive data from the Vp/Vn inputs

Configure the SPI controller for master operation with a clock rate as close to 50MHz as possible. (Note that 50MHz is the maximum frequency for the DAC on the Pmod DA4.)

Configure the interrupt controller for handling SPI interrupts.

Configure the GPIO with eight outputs to drive the LEDs and four inputs to read the switches.

Within the main program loop, read a value from the XADC, scale it for the appropriate output value, and write the computed value to the Pmod DA4 before updating the status of the LEDs and switches.

This sequence gives us the ability to read in a XADC values and output a scaled version over the Pmod DA4. Within the application, any variable we wish to be able to update using μC/Probe needs to be declared as a global variable. Therefore, in this example, the XADC values, the value to be written to the Pmod DA4, and the LED and switch variables are all declared globally.

To use the oscilloscope, we need to add some target code. This code is defined in three files provided on the Micrium μC/Probe download page. This download also contains the code necessary for implementing a μC/Probe interface to a target using RS232, USB, or Ethernet instead of JTAG.

The three files we need to map into our design are found under the directory:

<download path>\Micrium-Probe-TargetCode-410\Micrium\Software\uC-Probe\Target\Scope

The first two files, probe_scope.c and probe_scope.h, define the oscilloscope’s behavior and should be left unchanged. Add them to SDK as new include directory paths. The file within the cfg directory, probe_scope_cfg.h, defines the scope configuration. This file allows us to define the number of active channels, the maximum number of samples, support for 16 and 32-bit variables and the sampling frequency default. Copy this file into your working directory.

To make use of the files we have just added, call probe_scope_init() in the main application to initialize the oscilloscope at program start. Samples are then captured using the function probe_scope_sampling(), which is called when we wish to take a sample for the oscilloscope.

In this example I have called the sampling function at the end of the XADC/Pmod DA4 write loop. However, it can also be used with a timer and called during the ISR.

With the target code included and the main application ready, I built a target application boot file and booted the MicroZed.

I used my Digilent Analog Discovery module (since superseded by the Analog Discovery 2 module) to provide a stimulus waveform for the XADC and to capture the output from the Pmod DA4. The Analog Discovery module allows me to change the stimulus as desired and to monitor the Pmod DA4 output. Of course the waveforms I see using the Analog Discovery module will also be displayed on the μC/Probe oscilloscope.

Test Set up with the MicroZed, MicroZed IO Carrier Card, Segger JTAG probe, and Analog Discovery module

I created a simple dashboard within the μC/Probe application that allows me to change the output signal’s amplitude and the LEDs’ status and to monitor the DIP-switch settings on the IO Carrier Card. Doing all of this is simple with the μC/Probe application. We do the same as we did before: drop the graphical component(s) we desire on the dashboard and then associate the appropriate variables in the ELF. Only this time, instead of just monitoring variable values we will also manipulate them in the case of the output scale and LEDs.

To scale the Pmod DA4 output, I placed a horizontal slider and associated the slider with the float variable “scale” from the ELF. I also changed the slider’s full-scale value from 100 to 1.0 using the properties editor.

For each of the LEDs, I used graphical toggle buttons and associated each button with appropriate LED variable within the ELF. Finally, for each of the switches, I placed a graphical LED on the dashboard and configured the graphical LED to illuminate when its associated variable was set.

To create an oscilloscope within the dashboard, right click on the project under the workspace explorer and select the oscilloscope. This will create a new oscilloscope tab on the dashboard. As before, we can associate the variable from the ELF with each of the enabled channels by dragging and dropping as we do for any application.

Adding the Oscilloscope Tab to μC/Probe’s dashboard

Associating an ELF variable with Oscilloscope channel

To be able to see both tabs on the dashboard at the same time, I combed them as shown below. I did this by right-clicking on a tab and selecting “tile horizontally.”

Control and Oscilloscope combined on one μC/Probe dashboard

This approach does hide the oscilloscope control panel. However, you can open the oscilloscope control panel by clicking on “Scope Settings” at the bottom of the display. Doing so will open a traditional Oscilloscope control panel where you can set the triggering, timebase, etc.

Oscilloscope control panel, opened

Putting all of this together allowed me to control the amplitude of the output waveform on the Pmod DA4 using the slider and to control the LED status using the toggle buttons. I can of course see changes in both the input and output stimulus using μC/Probe’s oscilloscope and view the switch status via the simulated LEDs on the dashboard.

To demonstrate all of this in action I created a very short video:

The screen shots below also demonstrate the oscilloscope working.

Capturing the initial sine wave input

Output value to the DAC with the slider in the nominal position

I will be using μC/Probe in future blogs when I want to interact with the application software running on my Zynq target. I continue to be very impressed with μC/Probe’s capabilities.

The following links were useful in developing this blog:

You can find the example source code on the GitHub.

Adam Taylor’s Web site is http://adiuvoengineering.com/.

If you want E book or hardback versions of previous MicroZed chronicle blogs, you can get them below.

First Year E Book here

First Year Hardback here.

Second Year E Book here

Second Year Hardback here