Read binary data from SPI instrument
The interface object must be connected to the device with the
function before any data can be read from the device, otherwise an error is returned. A
connected interface object has a
ConnectionStatus property value of
Available options for
N – read at
N values into a column vector.
count cannot be
The SPI protocol operates in full duplex mode, input and output data transfers happen simultaneously. SPI communication requires N bytes of dummy data to be written into the device for reading N bytes of data from the device. The dummy data written is zeros.
Read Data from SPI Device
This example shows how to create a SPI object
and read data.
spi object called
s = spi('aardvark',0,0);
Connect to the chip.
Read data from the chip.
data = read(s,2);
Disconnect the SPI device and clean up by clearing the object.
s — SPI device
SPI device, specified as an
count — Number of values to read
Number of values to read, specified as a positive integer value.
Introduced in R2013b