Using Properties on the SPI Object
Use the properties
function on the spi
object
to see the available properties. In the preceding example, the syntax
would be:
properties(S)
The following shows the output of the properties from the preceding example, Transmitting Data over the SPI Interface.
>> properties(S) Properties for class instrument.interface.spi.aardvark.Spi: BitRate ClockPhase ClockPolarity ChipSelect Port BoardIndex VendorName BoardSerial ConnectionStatus TransferStatus
You can use these interface-specific properties with the spi
object.
Property | Description |
---|---|
BitRate | SPI clock speed. Must be a positive, nonzero value specified
in Hz. The default is 1000000 Hz for both the Aardvark
and NI-845x adaptors. To change from the default:
|
ClockPhase | SPI clock phase. Can be specified as 'FirstEdge' or 'SecondEdge' .
The default of 'FirstEdge' is used if you do not
specify a phase.
To change from the default:
|
ClockPolarity | SPI clock polarity. Can be specified as 'IdleLow' or 'IdleHigh' .
The default of 'IdleLow' is used if you do not
specify a phase.
To change from the default:
|
ChipSelect | SPI chip select line. The Aardvark adaptor uses 0 as
the chip select line since it has only one line, so that is the default
and only valid value. |
Port | Use to create spi object. Port number of
your hardware, specified as the number 0 . The Aardvark
adaptor uses 0 as the port number when there is
one adaptor board connected. If there are multiple boards connected,
they could use ports 0 and 1 .
Specify port number as the third argument when you create the spi object:
|
BoardSerial | Unique identifier of the SPI communication device. |
VendorName | Use to create spi object. Adaptor board
vendor, must be set to 'aardvark' , for use with
Total Phase Aardvark adaptor or 'ni845x' for use
with the NI-845x adaptor. Specify the vendor as the first argument
when you create the spi object:
|
BoardIndex | Use to create spi object. Specifies the
board index of the hardware. Usually set to 0 .
Specify board index as the second argument when you create the spi object:
|
ConnectionStatus | Returns the connection status of the SPI object. Possible values
are Disconnected (default) and Connected . |
TransferStatus | Returns the read/write operation status of the SPI object.
Possible values:
|
The properties all have defaults, as indicated in the table.
You do not need to set a property unless you want to change it to
a different value from the default. Aside from the three properties
required to construct the object – VendorName
, BoardIndex
,
and Port
– any other property is set using
the .dot notation syntax:
<object_name>.<property_name> = <value>
Here are a few examples of using this syntax.
Change the BitRate from the default of 1000000 to 500000 kHz S.BitRate = 500000 Change the ClockPhase from the default of 'FirstEdge' to 'SecondEdge' S.ClockPhase = 'SecondEdge'
where S
is the name of the object used in
the examples.
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.