Use this example to review and configure the SPI project files for pins, specifications, levels, timing, and patterns. Then load and burst the pattern and evaluate the results in the editor or from the provided LabVIEW, .NET, or C code.

Purpose

This example demonstrates how to burst a Serial Peripheral Interface (SPI) command at a 1MHz vector rate from the Digital Pattern Editor on a digital pattern instrument using the NI-Digital Pattern Driver software in LabVIEW, Microsoft .NET, and C. You can use this example to help you learn key concepts or to serve as a starting point for applications you create.
Note To pass all test steps, connect digital channels 2 and 3 (MOSI and MISO). Create a manual loopback connection on the digital pattern instrument. The example runs without the loopback connection, but each test step reports a failure. NI does not provide a DUT for the example.

Example File Location

  • LabVIEW:

    <Program Files>\NI\LVAddons\nidigital\1\examples\instr\niDigital

  • C and.NET:

    <Public Documents>\National Instruments\NI-Digital\Examples\Getting Started

Highlighted Features

  • Digital Pattern Editor

  • NI-Digital Pattern Driver

Major API

NI-Digital Pattern Driver

Prerequisites

Note To pass all test steps, connect digital channels 2 and 3 (MOSI and MISO). Create a manual loopback connection on the digital pattern instrument. The example runs without the loopback connection, but each test step reports a failure. NI does not provide a DUT for the example.

How to Use This Example

Complete the following steps before you review the Digital Pattern Editor components and then use LabVIEW, Microsoft .NET, or C to burst a pattern and view the results.

  1. Manually connect the digital pattern instrument channels 2 and 3 together (pins MOSI and MISO).
  2. In the Start menu, navigate to NI Digital Pattern Editor in the National Instruments folder to launch the Digital Pattern Editor.

Review Components

  1. Open the SPI Example.digiproj project, located in the appropriate development folder in the Getting Started directory.
  2. Review the following files in the Project Explorer window.
    • The pin map and the channel map
    • Specifications
    • Digital pin levels
    • Digital time sets
    • Digital pattern
    • Shmoo plot
    You can use folders to organize and manage files in a project. Double-click the file in the Project Explorer window to open it.
  3. Review the options in the Pin View pane to the right of the document workspace. Use the Pin View pane in conjunction with the pattern document during debugging. You can view and modify these settings for one pin at a time:
    • Pin driver
    • Active load
    • Comparators
    • PPMU
    • NI-DCPower instrument settings
  4. Double-click the SPI Example.pinmap file in the Project Explorer window to launch the pin editor and the channel map editor. The editor displays an editable hierarchical view of the following elements in the pin file and channel map file:
    • Instruments
    • Pins
    • Pin Groups
    • Sites
    • Connections
  5. On the Pin Map tab, select the default PXI1Slot2 {Digital Pattern} entry in the <Instruments> section. Then change the corresponding Name field to match the name of the digital pattern instrument resource in your system.
  6. Double-click the Specifications.specs file in the Project Explorer window to launch the specifications document. Use the specifications document to define a set of variables and associated numeric values. You can reference these variables and values in levels, timing, and other specifications files. Review the vcc variables and period variables.
  7. Double-click the PinLevels.digilevels file in the Project Explorer window to launch the levels document. The levels document displays voltage levels. It also provides a description for digital pins and pin groups defined in the pin and channel map.
  8. Click the Apply Levels button Load or Apply button to load the levels values on the instrument.
  9. Double-click the Timing.digitiming file in the Project Explorer window to launch the timing document. The timing document displays the time set components. The components include the format and the edge placement that shape the digital waveform on a per-pin basis.
  10. Select the Apply Time Sets button Load or Apply button to load the time set values on the instrument.

Burst Pattern and View Results

  1. Double-click the SPI Pattern.digipat file in the Project Explorer window to launch the pattern document grid view. The view displays the following components of the binary pattern file.
    • Time sets
    • Labels
    • Opcodes
    • Vector identifiers
    • Data to send to or received from pins and pin groups
    • Comments for each vector
  2. Select the Load Pattern button Load or Apply button to load the pattern on the instrument.
  3. Select the Burst button Burst button to burst the pattern on the instrument. If necessary, the editor prompts you to load the following data on the instrument.
    • Pattern
    • Time set
    • Levels
    The Passed/Failed/Disabled indicator displays whether the last pattern burst contains failures. History RAM logging does not affect the result. The indicator also shows whether the site was disabled for the last pattern burst. Disabled sites do not return results. The Total Failures indicator displays the number of failures in the pattern. The Burst Complete indicator displays the timestamp of when the last pattern burst completed. Data cells showing pin state with a red background and red text indicate a failure.
  4. Double-click the Shmoo.digishmoo file in the Project Explorer window to launch the configured Shmoo plot. The Shmoo plot displays a dynamically updated intensity plot of pass and fail values for two variables. Select the variables from data in the following project files:
    • Specifications
    • Timing
    • Levels
    • Pin and channel map
    • Pattern files
  5. Select the Run Shmoo button Run Shmoo button icon to start the operation and view the results.
  6. Select Instruments » Disconnect to disconnect the instrument session.

Run the LabVIEW Example

  1. Open the SPI Example VI.
  2. On the block diagram, review the comments which explain each subVI. The VI calls the same project files that the SPI Example.digiproj project references. The files include:
    • Specifications
    • Timing
    • Levels
    • Pin and channel map
    • Pattern files
  3. On the front panel, select the digital pattern instrument resource in your system in the Resource Name control.
  4. Run the VI.

Run the Microsoft .NET Example

  1. Open the NIDigital.SPIExample.sln solution file in Microsoft Visual Studio.
  2. In MainForm.cs, review the comments which explain the NI-Digital Pattern Driver .NET API calls. The code uses the same project files that the SPI Example.digiproj project references. The files include:
    • Specifications
    • Timing
    • Levels
    • Pin and channel map
    • Pattern files
  3. Build and run the solution.
  4. On the main form, enter the name of the digital pattern instrument resource in your system in the Digital Instrument text box.
  5. Select the Run Test button.

Run the C Example

  1. Open the NIDigital.SPIExample.sln solution file in Microsoft Visual Studio.
  2. In SPI Example.c, review the comments which explain the NI-Digital Pattern Driver C API calls. The code uses the same project files that the SPI Example.digiproj project references. The files include:
    • Specifications
    • Timing
    • Levels
    • Pin and channel map
    • Pattern files
  3. In the main function, enter the name of the digital pattern instrument resource in your system as the initial value of deviceID.
  4. Build and run the solution.