Write binary data to SPI instrument
write(OBJ, A) writes the data, A, to the SPI instrument
connected to interface object, OBJ. OBJ must be a 1-by-1 SPI interface object. By
'uint8' precision is used.
The interface object must be connected to the device with the
connect function before any data can be read from or written
to the device, otherwise an error is returned. A connected interface object has a
ConnectionStatus property value of connected.
The SPI protocol operates in full duplex mode, input and output data transfers happen simultaneously. For every byte written to the device, a byte is read back from the device. This function will automatically flush the incoming data.
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.
This example shows how to create a SPI object
s, and read and
spi object called
s = spi('aardvark', 0, 0);
Connect to the chip.
Write to the chip.
dataToWrite = [2 0 0 255] write(s, dataToWrite);
Disconnect the SPI device and clean up by clearing the object.