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 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 Aardvark driver installed, see Install the Aardvark Support Package to install it via the Support Package Installer.

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.

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 the NI-845x I2C/SPI Interface Support Package to install it via the Support Package Installer.

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.

Was this topic helpful?