Main Content

SPI WriteRead

Write data to and read data from an SPI device

Add-On Required: This feature requires the Simulink Support Package for Arduino Hardware add-on.

  • SPI WriteRead block

Libraries:
Simulink Support Package for Arduino Hardware / Common

Description

Write data to and read data from an SPI device connected to your Arduino board. Using this block, you can access an SPI device to measure quantities such as temperature, and pressure. You can also access an SPI device to support Wi-Fi® connectivity, and to access an SD card to store data.

Click View pin map to open the Arduino Pin Mapping table.

To know how to assign pins for the block, see Pin Mapping for Arduino Timer Independent Blocks.

Limitations

The following limitation is not applicable when using Arduino® MKR1000, Arduino MKR WIFI 1010, Arduino MKR ZERO, Arduino compatible ESP32 WROOM and WROVER, and Arduino Nano 33 IoT boards.

In a Simulink® model, the SPI WriteRead block is supported only if:

  • No blocks from the Ethernet shield library or the WiFi library are already present in the model.

  • External mode is over serial.

Ports

Input

expand all

The input port through which the block accepts a single dimensional array of values to write to the peripheral device.

Data Types: uint8 | uint16 | uint32

Output

expand all

Output port from which the block receives data from SPI peripheral device.

Data Types: uint8 | uint16 | uint32

Parameters

expand all

Specify the SPI module on the Arduino hardware to communicate with SPI peripherals. For more information on Arduino pin mapping and modules that hardware boards support, see Pin Mapping for Arduino Timer Independent Blocks.

Enter the pin number on the Arduino board to which the SPI peripheral device is connected. The SPI controller pulls the CS pin of the selected peripheral to a low (0) value to start the communication. See Pin Mapping for Arduino Timer Independent Blocks to know the SS pin restriction with different Arduino boards.

Version History

Introduced in R2016b