Getting Started - SPI Example

Digital Pattern Help

Edition Date: May 2018

Part Number: 375145e

»View Product Info
Download Help (Windows Only)

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 Note   For this example to produce passing results, you must connect digital channels 2 and 3 together (pins MOSI and MISO) and you must manually make a loopback connection to a Digital Pattern Instrument. The example runs without the loopback connection but reports failures on each test step. NI does not provide a DUT for this example.

Example File Location

<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 Note   For this example to produce passing results, you must connect digital channels 2 and 3 together (pins MOSI and MISO) and you must manually make a loopback connection to a Digital Pattern Instrument. The example runs without the loopback connection but reports failures on each test step. NI does not provide a DUT for this 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 environment folder in the <Public Documents>\National Instruments\NI-Digital\Examples\Getting Started directory.
  2. Review the list of files in the Project Explorer window, such as the pin and channel map, specifications, digital pin levels, digital time sets, digital pattern, and 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. You can use the Pin View pane in conjunction with the pattern document during debugging to interactively view and modify the current state of the pin driver, active load, comparators, PPMU, and NI-DCPower instrument settings for a single pin at a time.
  4. Double-click the SPI Example.pinmap file in the Project Explorer window to launch the pin and channel map editor, which displays an editable hierarchical view of the Instruments, Pins, Pin Groups, Sites, and Connections elements in the pin and channel map file.
  5. On the Pin Map tab, select the default PXI1Slot2 {Digital Pattern} entry in the <Instruments> section and 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, which you can use to define a set of variables and associated numeric values that you can reference in levels, timing, and other specifications files. Review the vcc and period variables.
  7. Double-click the PinLevels.digilevels file in the Project Explorer window to launch the levels document, which displays voltage levels and a description for digital pins and pin groups defined in the pin and channel map.
  8. Click the Apply Levels button Load or Apply 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, which displays components of the time sets, including the format and edge placement that shape the digital waveform on a per-pin basis.
  10. Click the Apply Time Sets button Load or Apply 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, which displays components of the binary pattern file, including time sets, labels, opcodes, vector identifiers, data to send to or received from pins and pin groups, and comments for each vector.
  2. Click the Load Pattern button Load or Apply to load the pattern on the instrument.
  3. Click the Burst button Burst to burst the pattern on the instrument. If necessary, the editor prompts you to load the pattern, time set values, and levels values on the instrument. The Passed/Failed/Disabled indicator displays whether the last pattern burst includes any failures, regardless of what you log to History RAM, and whether the site was disabled for the last burst of the pattern. 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. Pin state data cells 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, which displays a dynamically updated intensity plot of pass and fail values for two variables you specify using the specifications, timing, levels, pin and channel map, and pattern files in the project.
  5. Click the Run Shmoo button Run Shmoo 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 pin and channel map, specifications, levels, timing, and pattern files referenced in the SPI Example.digiproj project you reviewed in the digital pattern editor.
  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 pin and channel map, specifications, levels, timing, and pattern files referenced in the SPI Example.digiproj project you reviewed in the digital pattern editor.
  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. Click 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 pin and channel map, specifications, levels, timing, and pattern files referenced in the SPI Example.digiproj project you reviewed in the digital pattern editor.
  3. In the main function, enter the name of the digital pattern instrument resource in your system as the initialization value for the variable deviceID.
  4. Build and run the solution.

WAS THIS ARTICLE HELPFUL?

Not Helpful