SPI Controller Transfer
Write data to and read data from SPI peripheral device
Simulink Coder Support Package for BBC micro:bit/Basic
Simulink Coder Support Package for STMicroelectronics Nucleo Boards/ Common
Simulink Coder Support Package for STMicroelectronics Discovery Boards/ STM32F746G-Discovery
Simulink Coder Support Package for STMicroelectronics Discovery Boards/ STM32F769I-Discovery
The SPI controller Transfer block writes data to and reads data from a peripheral device over the Serial Peripheral Interface (SPI) interface. The block outputs an array of the same size and data type as the input values. You can use this block with Byte Pack and Byte Unpack blocks to support heterogeneous data type transfers.
Using this block, you can access an SPI device to measure quantities such as temperature, pressure.
For more information on SPI communication, see Support SPI Communication.
SDO — Data to write to registers of an SPI peripheral
The port accepts the serial data out (SDO) to write to the registers of a peripheral device over the SPI interface.
SDI — Data read from registers of an SPI peripheral
The port outputs the data read from the registers of a peripheral device over the SPI interface.
SPI module — SPI module to write and read
Specify the SPI module to which the SPI peripheral device is connected.
Chip select pin — Pin connected to the SPI peripheral device
Specify the pin name on the board to which the SPI peripheral device is connected. The SPI controller pulls the SS pin of the selected peripheral to a low (0) value to start the communication. The peripheral is selected depending on the pin polarity that you specify in the Chip select pin polarity parameter. The controller can select only one peripheral at a time.
First bit to transfer — First bit to transfer for SPI communication
significant bit (MSB) (default) |
Least significant bit
Select the order in which the data is transmitted.
Most significant bit (MSB) — Select MSB to send the most significant bit (MSB) first.
Least significant bit (LSB) — Select LSB to send the least significant bit (LSB) first.
Mode (Clock polarity and phase) — Mode of SPI communication
0 (default) |
An SPI controller sets the clock polarity (CPOL) and the clock phase (CPHA).
The combination of polarity and phase are referred to as SPI modes. The SPI modes 0–3 are shown in the table.
|Mode||Clock Polarity (CPOL)||Clock Phase (CPHA)|
For more information on register read/write, see SPI Transfer Modes.
Chip select pin polarity — Logic level to establish SPI
low (default) |
The logic levels supported by Chip select pin to select the SPI peripheral device.
Active low — The device is enabled on logic low. The SPI peripheral device gets enabled when its SS pin is set to low.
Active high — The device is enabled on logic high. The SPI peripheral device gets enabled when its SS pin is set to high.