Debugging Blackfin Applications
Overview
The benefits of the LabVIEW graphical programming environment are numerous. Key to the ease of use is the LabVIEW interactive front panel/block diagram approach. With any embedded application on unproven hardware, the software development tools must provide a complete toolchain that both simplifies the design process and allows you to dig into the details. The NI LabVIEW Embedded Module for ADI Blackfin Processors delivers an integrated, embedded programming experience by providing graphical programming for embedded systems, hundreds of analysis and signal processing VIs, and integrated I/O. Analog Devices VisualDSP++ is included with the Embedded Module for Blackfin Processors to enable fully integrated debugging capability. By seamlessly integrating with the VisualDSP++ compiler, linker, and debug connection, you can easily single-step through the graphical code in LabVIEW while at the same time visualizing the embedded code within the debugger, both C and ASM. LabVIEW integrates VisualDSP++-specific-compiler options, such as the ability to enable cache, linker elimination, and view live front panel updates via Background Telemetry Channel (BTC) technology. You also can use VisualDSP++ compiler flags if you need specific options other than what LabVIEW provides.
This document describes the different debugging features you can use to debug Blackfin applications, such as using the front panel, using breakpoints and probes on the block diagram, and using dual debugging to simultaneously step through the graphical code in LabVIEW and the generated C code in VisualDSP++.
Table of Contents
Using the Front Panel
Using the Embedded Module for Blackfin Processors, you can instrument your running code using the front panel in LabVIEW. In LabVIEW for Windows, the front panel provides a user interface for a VI or application. In the Embedded Module for Blackfin Processors, you can use the front panel as a subroutine header declaration and as a dynamic debug interface. When using the front panel as a debug interface, the Blackfin target sends data variables to the front panel on the host PC in real time using a communication you define. You can use instrumented or non-instrumented debugging with Blackfin applications.
- Instrumented debugging using a serial or TCP port--The LabVIEW C Code Generator adds a communication layer to the generated C code for synchronization and data transfer. Instrumented debugging provides the closest experience to LabVIEW for Windows. The more front panels that are open, the more target execution performance is affected.
- Non-instrumented debugging using a JTAG/EZ-KIT USB connection--The application code is smallest when you use non-instrumented debugging. The JTAG emulator connects directly to the Blackfin processor and uses processor cycles to send data via a Background Telemetry Channel (BTC) to the front panel running on the host PC. Non-instrumented debugging does not add an additional communication layer to the generated code. This document uses the non-instrumented debugging mode.

Complete the following steps to enable front panel updates for Blackfin targets.
1. Launch LabVIEW and select Analog Devices ADSP-BF537, VDK Module from the Execution Target pull-down menu.
2. Open a blank VI and select File»Save. Save the VI as power.vi.
3. Click the Run button. LabVIEW prompts you to create an Embedded Project. Click the New button to open the Embedded Project Manager.

4. The VI name appears in the Project name text box by default. Click the OK button to name the project power.lep.


5. Place the BF Set Max Frequency for Voltage VI located on the Functions»Blackfin»Power palette on the block diagram.

6. Right-click the voltage level input and select Create»Control from the shortcut menu so you can change the voltage supplied to the Blackfin chip as you develop the application. LabVIEW automatically adds the control to the front panel. As discussed earlier, the front panel executes in real-time on the host PC as the application runs on the Blackfin target when you use front panel updates for debugging.
You can use the BF Get Frequency VI, which is not shown in this example, to obtain the frequency of operation for the selected voltage value.7. Enclose the BF Set Max Frequency for Voltage VI in a While Loop located on the Functions»Structures palette. Right-click the conditional terminal and select Create Constant from the shortcut menu. Leave the constant as FALSE, which is the default, so the While Loop runs continuously.

8. Configure the build options.
- a. Select Target»Build Options in the Embedded Project Manager to open the Blackfin Build Options dialog box.
b. Select Debug from the Build Configuration pull-down menu.
c. Select Non-intrusive (via JTAG/EZ-KIT USB) from the Debug mode pull-down menu.
d. Place a checkmark in Generate guard code in the code generation option.
e. Click the OK button.
9. Select Target»Debug in the Embedded Project Manager to build, download, and run the application on the Blackfin target in debug mode.10. As the application is running, you can change the Blackfin core voltage. If you connect the EZ-KIT to a digital multimeter (DMM) or a data acquisition device using the NI ELVIS interface on the EZ-KIT, you can verify that the processor operating voltage is changing.
11. The following graphic shows a simple Windows-based EXE that is connected to a DMM.
Using Breakpoints and Probes on the Block Diagram
You can use breakpoints and probes in LabVIEW. You can set probes and breakpoints by right-clicking a wire and selecting Probe or Set Breakpoint from the shortcut menu.


Alternatively, you can place a probe on a wire instead of setting a breakpoint. A floating Probe window appears after you create each probe. LabVIEW numbers the Probe windows automatically and displays the same number in a glyph on the wire you click. Use the Probe window to observe the state of the variable. The value in the Probe window updates in real time as the value changes in the code executing on the Blackfin processor. You can use LabVIEW and VisualDSP++ to simultaneously debug the LabVIEW block diagram and the corresponding generated C code. The application we will create in this section is more complicated than the previous examples.
1. Select Target»Build Options in the Embedded Project Manager and change the debug mode to Non-intrusive (via JTAG/EZ-Kit USB) to enable front panel debugging.

2. Build the following application.
- a. The Timed Loop located on the Functions»Structures palette executes one or more subdiagrams sequentially each iterations of the loop at the period you specify. Double-click the Timed Loop and set the period to 500.
b. The Initialize Array function located on the Functions»Array palette creates an n-dimensional array in which every element is initialized to the value of the element input. Create constants for the element and dimension inputs, wire the output to the Timed Loop, right-click the tunnel going into the Timed Loop and select Replace with Shift Register from the shortcut menu.
c. The Rotate 1D Array function located on the Functions»Array palette rotates the elements of the array input the number of places and in the direction indicated by the n input. Connect the left shift register to the array input and create a constant for the n input.
d. The Random Number (0-1) function located on the Functions»Numeric palette produces a double-precision, floating-point number between 0 and 1. Wire the Random Number function to the y input and create a constant from the x input of the Multiply function. Right-click the constant and select Change to Control from the shortcut menu. Right-click the control and remove the checkmark next to View as Icon in the shortcut menu.
e. The Replace Array Subset function located on the Functions»Array palette replaces an element or subarray in an array. Wire the output of the Multiply function to the new element/subarray input, create a constant for the index input, wire the output of the Rotate 1DArray function to the n-dimension array input, and wire the output array output to the tunnel coming out of the Timed Loop.
f. The Mean function located on the Functions»Mathematics»Analyze»Probability and Statistics computes the mean of values. Wire the output array output of the Replace Array Subset function to the X input of the Mean function, right-click the mean output and select Create»Indicator from the shortcut menu. Right-click the indicator and remove the checkmark next to View as Icon in the shortcut menu.
3. Next, configure the application for dual debugging between LabVIEW and VisualDSP++. As the code executes on the Blackfin processor, you can simultaneously single-step through the LabVIEW code on the block diagram and the corresponding C code. Select Target»Configure Target in the Embedded Project Manager to open the VisualDSP++ Target Configuration dialog box.
4. Click the Debug Options tab in the VisualDSP++ Target Configuration dialog box, place a checkmark in the Debug using the VisualDSP++ IDDE checkbox and click the OK button.

5. Launch VisualDSP++.
Note: If VisualDSP++ is not open when you try to debug the Blackfin application, you receive the following reminder:

6. Set a breakpoint on the Multiply function in LabVIEW by right-clicking the function and selecting Set Breakpoint from the shortcut menu. A red border appears around the Multiply function.
7. Move the windows of the two environments, LabVIEW and VisualDSP++, to tile them in a side-by-side configuration. Click the Debug button in the Embedded Project Manager to build, download, and begin debugging the Blackfin application.
- 1. Observe the yellow arrow enclosed in the red circle in VisualDSP++. The red circle represents the breakpoint and the yellow circle represents the current step.
2. You should see the Multiply function flashing in LabVIEW, which is where you defined the breakpoint.
3. Click the Step Over button in LabVIEW.
8. Note the following as VisualDSP++ and LabVIEW step over the Multiply function simultaneously:
- 1. The breakpoint (red circle) in VisualDSP++ is the function that was just stepped over.
2. The current position (yellow arrow and blue highlighted row) represents the next piece of code.
3. The code itself has general comments such as “Replace Array” and then line-by-line comments that were inserted by the LabVIEW C Code Generator.
4. In LabVIEW, the breakpoint is represented with the red outline on the Multiply function.
5. The next step in the code is flashing (Replace Array function).
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/).







