The SPI Basic API provides the most fundamental SPI transaction type: write/read. You can access most off-the-shelf SPI devices using this transaction. The SPI Basic API allows you to easily and quickly develop applications to communicate with these devices. For those situations in which the SPI Basic API does not provide the functionality you need, use the SPI Scripting API to create custom SPI transactions.

When you use the SPI Basic API, the first step is to create an SPI configuration to describe the communication requirements between the 845x and the SPI device. To make an SPI configuration, create an SPI configuration reference and set the appropriate properties as desired. You can then read or write data to the SPI device.

The following figure describes the programming model for the NI-845x SPI Basic API. Within the application, you repeat this programming model for each SPI device. The figure is followed by a description of each step in the model.

NI-845x SPI API Basic Programming Model

SPI Configure

Use the NI-845x SPI Configuration Property Node in LabVIEW and ni845xSpiConfiguration* calls in other languages to set the specific SPI configuration that describes the characteristics of the device to communicate with.

SPI Write Read

Use NI-845x SPI Write Read.vi in LabVIEW and ni845xSpiWriteRead in other languages to exchange an array of data with an SPI slave device.

SPI Timing Characteristics

The following figure and tables show the timing characteristics of the SPI bus when using the SPI Basic API. If the timing characteristics of your device do not fit within these parameters, you can use the SPI Scripting API to adjust the bus characteristics to match those of your device.

SPI Waveform

NI USB-8451 Basic API SPI Timing Characteristics

Symbol Parameter Min Max Units
t1 CS(0:7) assertion to first SCLK edge 5 15.4 µs
t2 SCLK period 0.08333 20.83 µs
t3 SCLK setup time 8.5 19 µs
t4 Last SCLK edge to CS(0:7) deassertion 7.4 8.24 µs

NI USB-8452 Basic API SPI Timing Characteristics

Symbol Parameter Min Max Units
t1 CS(0:7) assertion to first SCLK edge 2.2 5 + ½ t2 µs
t2 SCLK period 0.02 1000 µs
t3 SCLK setup time 2.0 5 + ½ t2 µs
t4 Last SCLK edge to CS(0:7) deassertion 2.2 5 + ½ t2 µs