Main Content

Configuring SPI Communication

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

Configuring Aardvark

To use the SPI interface with the Aardvark adaptor, you must download the Hardware Support Package to obtain the necessary files. You must also download the USB device driver from the vendor.

If you do not have the Aardvark driver installed, see Install Instrument Control Toolbox Support Package for Total Phase Aardvark I2C/SPI Interface.

The aardvark.dll file that comes with the Total Phase Aardvark adaptor board must be available in one of these locations for use on Windows® platforms:

  • The location where MATLAB® was started from (bin folder)

  • The MATLAB current folder (PWD)

  • The Windows folder C:\winnt or C:\windows

  • The folders listed in the path environment variable

Ensure that the Aardvark adaptor is installed properly.

Look at the adaptor properties.

Create a SPI object using the spi function. 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.

S = spi('aardvark', 0, 0);

Display the object properties.

The communication settings properties reflect what was used to create the object – BoardIndex of 0 and Port of 0. For information about other properties, see Using Properties on the SPI Object.

Note

To get a list of options you can use on a function, press the Tab key after entering a function on the MATLAB command line. The list expands, and you can scroll to choose a property or value. For information about using this advanced tab completion feature, see Using Tab Completion for Functions.

Configuring NI-845x

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

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.

Ensure that the NI-845x adaptor is installed properly.

Look at the NI-845x adaptor properties.

Create a SPI object using the spi function. The example in the next section uses a SPI object called s2 that communicates with an EEPROM chip. Create the object using the BoardIndex and Port numbers, which are 0 in both cases.

s2 = spi('ni845x', 0, 0);

Display the object properties.

The communication settings properties reflect what was used to create the object – BoardIndex of 0 and Port of 0. For information about other properties, see Using Properties on the SPI Object.

Note

To get a list of options you can use on a function, press the Tab key after entering a function on the MATLAB command line. The list expands, and you can scroll to choose a property or value. For information about using this advanced tab completion feature, see Using Tab Completion for Functions.