SPI Register Read
Read data from SPI slave device register
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 Register Read block reads the data from registers of a slave device over the Serial Peripheral Interface (SPI) interface. Using this block, you can access an SPI device to measure quantities such as temperature, pressure or to support EEPROM.
For more information on SPI communication, see Support SPI Communication.
MISO — Data read from registers of an SPI slave device
The port outputs the data read from the registers of a slave device over the SPI interface.
SPI module — SPI module to read data
Specify the SPI module to which the SPI slave device is connected.
Slave select pin — Pin connected to the SPI slave device
Specify the pin name on the board to which the SPI slave device is connected. The SPI master pulls the SS pin of the selected slave to a low (0) value to start the communication. The slave is selected depending on the pin polarity that you specify in the Slave select pin polarity parameter. The master can select only one slave at a time.
First bit to transfer — First bit to transfer for SPI communication
Most significant bit (MSB) (default) |
Least significant bit (LSB)
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 master 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.
Register address — The SPI slave register address to read data
Specify this address as an integer or in hexadecimal format
hex2dec(), for example, ‘hex2dec(‘20’)’.
Output data type — Data type of data read from the SPI slave device
int8 (default) |
Specify the type of data read from the register of the SPI slave device.
Output data length — Data size to read from the SPI slave device
1 (default) |
integer greater than or equal to 0
Specify the length of data read from the register of the SPI slave device.
Sample time — Frequency to read data from the SPI slave device
Specify how often the block reads data from the SPI slave device.
When you specify this parameter as
determines the best sample time for the block based on the block context
within the model.
Slave select pin polarity — Logic level to establish SPI communication
Active low (default) |
The logic levels supported by Slave select pin to select the SPI slave device.
Active low — The device is enabled on logic low. The SPI slave device gets enabled when its SS pin is set to low.
Active high — The device is enabled on logic high. The SPI slave device gets enabled when its SS pin is set to high.