Overview
Any software application will inevitably contain bugs during the development cycle. In order to correct these software flaws, developers need access to powerful debugging tools that allow them to be more efficient as well as be able to dig into the detailed operation of their application. The LabVIEW Embedded Module for ARM Microcontrollers provides a robust debugging environment that enables programmers to easily debug embedded code in a manner similar to debugging applications intended for desktop environments. Additionally, developers using LabVIEW in conjunction with Keil uVision can debug LabVIEW block diagrams alongside the C and assembly code running on their ARM microcontroller. This document describes the many ways to connect your embedded target, techniques for debugging applications, and how to step through LabVIEW and generated C code simultaneously.
Table of Contents
Enabling debug modes for ARM microcontrollers
Before we can begin debugging our application we must enable debugging through the Build Specification. The following steps illustrate how to enable debugging.
1. From the Project Explorer window, expand Build Specifications. Right click and select Properties.

2. This will bring up the Build Specification Properties window. Select Application Information from the Category column.

3. From the Application Information category, ensure that the Enable debugging checkbox is selected. Under Debug Options, select to either Run on target using ULINK2 or Run on host computer using simulator. Choose the ULINK2 option to debug if you have hardware available and wish to test your code’s operation in a real environment. This approach takes more time to load the software onto the development target; however you can test your design’s behavior in real-world situations. Choose the Simulator if you do not have hardware present or want to perform rapid testing in a simulated environment.

4. Next select Advanced Debugging Options from the category list. Under Debug mode, select one of the following options – Serial port, TCP port, or USB ULINK2 JTAG Debugging. These modes are described in further detail later in the document.

5. Click the OK button. Debugging is now enabled. In the Project Explorer window right-click the Application and select Run.

Basic debugging techniques
As with debugging any LabVIEW application, using breakpoints and probes can be especially useful in finding programming errors. To create a breakpoint or probe, right-click a wire and select Probe or Set Breakpoint from the shortcut menu.

If you set a breakpoint, a red dot appears on the wire to represent the breakpoint in the graphical code. If you run the application in debug mode, you can single step and step over the code using the buttons on the toolbar once a breakpoint is reached.

Create a probe to examine the value of of wire in the LabVIEW code. A probe will create a window that will be updated with the values of the wire during the execution of the program.

On an ARM microcontroller, we have another tool that we can use for our debugging - the Processor Status window. Debug statements can be displayed to the processor status window in three ways – printf statements within a C node, Console Out.vi from the ARM Palette, or the One Button Dialog.vi. The following block diagram shows each of these methods within a single timed loop.

When this code is executed, the strings are output to the Processor Status window.

Alternatively, debug statements can be captured through the serial port. This property is enabled through the Build Specification Properties window. From the Communication Options category, select the Serial port radio button from the console out box. This feature can only be enabled if Serial port debugging is not selected.

On an embedded target, the LabVIEW front-panels are not used if the system has debugging disabled.. If Enable debugging is not selected from the Build Specifications Properties window, the system will be deployed in release mode. Otherwise, front-panels can be updated with real-time information about the state of the system via USB, TCP, or Serial. Traditional LabVIEW front-panel indicators such as graphs, charts and numeric indicators are all valid debugging techniques for collecting interactive data from the system.
One final-technique to debug applications is to use the built-in ARM simulator. This allows for debugging without the presence of hardware. The simulator allows developers to debug and test their application with simulated hardware that is also capable of simulating the input to the system. The simulator is enabled through the Build Specification Properties window. Under the Application Information category, select Run on host computer using simulator.

For more in-depth information on how to use the LabVIEW ARM simulator can be found here.
Debugging over serial connection
The following steps demonstrate how to enable serial debugging.
1. In the Build Specification Properties windows select Serial port radio button from the Debugging Mode box.

2. Connect the target device to the development machine via serial cable. The target device needs to remain connected to the USB ULINK2 JTAG debugger for code deployment.
3. Build and Run the application. The application will now execute and update the front panel display.
Debugging over TCP/IP
The following steps demonstrate how to enable serial debugging.
1. In the Build Specification Properties windows select TCP port radio button from the Debugging Mode box.

2. From the Category column select Communication Options. This is used for configuring the network address settings of the device. Depending on the network configuration that is available in your development environment select either a static IP on use DHCP. Additionally, provide Host name for the device.

3. Connect the target device to the network via ethernet cable. The target device needs to remain connected to the USB ULINK2 JTAG debugger for code deployment.
4. Build and Run the application. The application will now execute and update the front panel display.
JTAG USB Debugging
The following steps demonstrate how to enable serial debugging.
1. In the Build Specifications Properties windows select USB ULINK2 JTAG radio button from the Debugging Mode box.

2. Build and Run the application. The application will now execute and update the front panel display. No additional cables are required.
Serial, TCP, and JTAG Comparison
Enabling serial and TCP debugging will add communication code to the LabVIEW code for data transfers using the bus protocols. Applications where code footprint is a concern, should avoid enabling serial or TCP debugging because the communication layer increases code size and may result in the application not being able to be deployed to the hardware. TCP will typically provide better performance over serial communication which may be necessary for applications with complex front panels. Both TCP and serial provide more deterministic debugging results than JTAG, but do impact the timing of the application.
JTAG communication does not require any additional cables, does not impact code size and does not impact the application timings. JTAG is the recommended method of debugging LabVIEW ARM applications.
One final consideration is debugging applications with front panels containing clusters of scalar or arrays of scalars. To accomplish this, the On-Chip Debugging Interface (OCDI) must be configured to allow this. Configuring is done by right-clicking the target and selecting Configure Target.

To enable scalar array and scalar cluster debugging, select the Allow debugging of scalar arrays and Allow debugging of scalar clusters checkboxes in the Configure Target window. An important consideration to be aware of when debugging is that arrays containing clusters and clusters containing arrays cannot be debugged via front panels. Additionally, serial communications to the device can be configured via this window if the target is being debugged via serial port.

Dual Debugging between LabVIEW and Generated C code
You can use LabVIEW and µVision to simultaneously debug the block diagram code while looking at corresponding C Code. The following steps illustrate how this is accomplished.
1. Create the LabVIEW VI that will be deployed to the target. The following VI will be used for this example:

2. Insert a breakpoint into the code as described in the Basic Debugging Techniques section.
3. From the Build Properties window, enable debugging through JTAG USB.
4. Right-click the target and select Show Keil uVision

5. The Keil µVision environment will now appear. Build and Run the LabVIEW application. Once the application has finished building and is deployed to your target, when the application hits the breakpoint that was set, both the LabVIEW diagram and the corresponding C code will be displayed on screen. From here it is possible to set new break points, check the c code that is being executed, interactively step through either the c code or the LabVIEW code.

Summary
LabVIEW enables developers to efficiently and easily debug their embedded application with front-panel connections, while providing a mechanism for digging into the low-level details of their application through an integrated debugging environment.
Reader Comments | Submit a comment »
Legal
This tutorial (this "tutorial") was developed by National Instruments ("NI"). Although technical support of this tutorial may be made available by National Instruments, the content in this tutorial may not be completely tested and verified, and NI does not guarantee its quality in any way or that NI will continue to support this content with each new revision of related products and drivers. THIS TUTORIAL IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND AND SUBJECT TO CERTAIN RESTRICTIONS AS MORE SPECIFICALLY SET FORTH IN NI.COM'S TERMS OF USE (http://ni.com/legal/termsofuse/unitedstates/us/).
