Getting Started - SPI Example
- Updated2026-10-20
- 6 minute(s) read
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.
- Manually connect the digital pattern instrument channels 2 and 3 together (pins MOSI and MISO).
- In the Start menu, navigate to NI Digital Pattern Editor in the National Instruments folder to launch the Digital Pattern Editor.
Review Components
- Open the SPI Example.digiproj project, located in the appropriate development folder in the Getting Started directory.
- 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
- 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
- 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
- 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.
- 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.
- 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.
- Click the Apply Levels
button
to load the levels values on the instrument. - 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.
- Select the Apply Time
Sets button
to load the time set values on the instrument.
Burst Pattern and View Results
- 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
- Select the Load Pattern
button
to load the pattern on the instrument. - Select the 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
- 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
- Select the Run Shmoo
button
to start the operation and view the results. - Select to disconnect the instrument session.
Run the LabVIEW Example
- Open the SPI Example VI.
- 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
- On the front panel, select the digital pattern instrument resource in your system in the Resource Name control.
- Run the VI.
Run the Microsoft .NET Example
- Open the NIDigital.SPIExample.sln solution file in Microsoft Visual Studio.
- 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
- Build and run the solution.
- On the main form, enter the name of the digital pattern instrument resource in your system in the Digital Instrument text box.
- Select the Run Test button.
Run the C Example
- Open the NIDigital.SPIExample.sln solution file in Microsoft Visual Studio.
- 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
- In the main function, enter the name of the digital pattern instrument resource in your system as the initial value of deviceID.
- Build and run the solution.