Main Content

Troubleshooting SPI Interface

Serial Peripheral Interface (SPI) is a synchronous serial data link standard that operates in full duplex mode. It is commonly used in the test and measurement field. Common uses include communicating with micro controllers, EEPROMs, A2D devices, embedded controllers, etc.

Instrument Control Toolbox™ SPI support lets you open connections with individual chips and to read and write over the connections to individual chips using an Aardvark or NI-845x host adapter. The primary uses for the spi interface involve the write, read, and writeAndRead functions for synchronously reading and writing binary data.

Supported Platforms

You need to have either a Total Phase Aardvark host adapter or an NI-845x adapter board installed to use the spi interface.

The SPI interface is supported on these platforms when used with the Aardvark host adapter:

  • Linux® — Red Hat® Enterprise Linux 4 and 5 with kernel 2.6, and possibly SUSE® and Ubuntu distributions.

  • Microsoft® Windows® 64-bit

Note

For R2018b and R2018a, you cannot use the Aardvark adapter for I2C or SPI interfaces on the macOS platform. You can still use it on Windows and Linux. For releases prior to R2018a, you can use it on all three platforms, including macOS.

The SPI interface is supported on these platforms when used with the NI-845x host adapter:

  • Microsoft Windows 64-bit

Adapter Requirements

You need either a Total Phase Aardvark host adapter or an NI-845x adapter board installed to use the spi interface. The following sections describe requirements for each option.

Aardvark-specific Requirements

To use the SPI interface with the Aardvark adapter, make sure you install the following software.

  1. Install the Total Phase USB Drivers for Windows or Linux. Verify that the Aardvark adapter appears in the Windows Device Manager under the USB section.

  2. Uninstall any existing Aardvark Software API on your computer. Download and install the Instrument Control Toolbox Support Package for Total Phase® Aardvark I2C/SPI™ Interface. For more information, see Install Instrument Control Toolbox Support Package for Total Phase Aardvark I2C/SPI Interface.

Make sure that the Aardvark adapter is connected to your computer using the USB connector.

Optionally, you can also check that the Aardvark adapter is working properly in the Total Phase Control Center Serial Software.

NI-845x-specific Requirements

To use the SPI interface with the NI-845x adapter, download the hardware support package to obtain the latest driver, if you do not already have the driver installed. If you already have the latest driver installed, you do not need to download this support package.

If you do not have the NI-845x driver installed, see Install Instrument Control Toolbox Support Package for National Instruments NI-845x I2C/SPI Interface to install it.

Configuration and Connection

  1. Make sure that you have the correct instrument driver installed for your device. Refer to your device’s documentation and the vendor’s web site.

  2. Make sure your device is supported in Instrument Control Toolbox. See Is My Hardware Supported?.

  3. You must have a Total Phase Aardvark host adapter or an NI-845x adapter board installed to use the SPI interface. Install the appropriate support package if you have not already. See Adapter Requirements.

    Make sure that your SPI adapter board is plugged into the computer running MATLAB®. You can verify that you have one of the adapters installed by using the instrhwinfo function with the spi interface name.

    If you do not see either aardvark or ni845x listed, you need to install one of the support packages or install the driver directly from the vendor.

  4. Make sure that Instrument Control Toolbox recognizes your device, by using the instrhwinfo function with the spi interface name, and your adapter name, either aardvark or ni845x. For example:

    You will need the information displayed to create the spi object. If your device is not displayed, check the previous steps.

  5. Make sure you can create the spi object. You must provide three arguments to create the object. BoardIndex and Port are both usually 0, and Vendor is either 'aardvark' or 'ni845x'. This example uses a SPI object called S that communicates to an EEPROM chip. Create the object using the BoardIndex and Port numbers, which are 0 in both cases.

    % Vendor = aardvark
    % BoardIndex = 0
    % Port = 0
    
    S = spi('aardvark', 0, 0);
  6. If you do not get an error, the object was created successfully. To verify, you can look at the object properties, using the name you assigned to the object, S in this case.

  7. Make sure you can connect to the device, using the connect function with the object name.

    connect(S);

    If you do not get an error, the connection was made successfully. If you do get an error, follow the steps in the error message and/or check the previous steps listed here.

  8. When you have connected, you can communicate with your device. See Transmitting Data over the SPI Interface for an example of reading and writing to a chip.