SPI Controller Transfer
Add-On Required: This feature requires the Embedded Coder Support Package for STMicroelectronics STM32 Processors add-on.
Libraries:
Embedded Coder Support Package for STMicroelectronics STM32 Processors /
STM32F2xx Based Boards
Embedded Coder Support Package for STMicroelectronics STM32 Processors /
STM32F3xx Based Boards
Embedded Coder Support Package for STMicroelectronics STM32 Processors /
STM32F4xx Based Boards
Embedded Coder Support Package for STMicroelectronics STM32 Processors /
STM32F7xx Based Boards
Embedded Coder Support Package for STMicroelectronics STM32 Processors /
STM32G4xx Based Boards
Embedded Coder Support Package for STMicroelectronics STM32 Processors /
STM32H7xx Based Boards
Embedded Coder Support Package for STMicroelectronics STM32 Processors /
STM32U5xx Based Boards
Embedded Coder Support Package for STMicroelectronics STM32 Processors /
STM32L475VG-Discovery (B-L475E-IOT01A)
Embedded Coder Support Package for STMicroelectronics STM32 Processors /
STM32F746G-Discovery
Embedded Coder Support Package for STMicroelectronics STM32 Processors /
STM32F769I-Discovery
Simulink Coder Support Package for STMicroelectronics Nucleo Boards /
Common
Description
The SPI Controller Transfer block accepts a 1-D array and outputs an
array of the same size of the uint8
, uint16
or
uint32
data types
The SPI Controller Transfer block writes data to and reads data from a peripheral device over the Serial Peripheral Interface (SPI). The block runs in controller mode. The block outputs an array of the same size and data type as the input values. You can use this block with the Byte Pack and Byte Unpack blocks for heterogeneous data type transfers.
Using this block, you can access an SPI device to measure quantities such as temperature and pressure.
The SPI receive interrupt is configured for a specific hardware board by navigating to Configuration Parameters > Hardware Implementation > Target hardware resources.
SPI Module is configured in STM32CubeMX project.
Launch the STM32CubeMX project. For more information, see Configure STM32 Processor-Based Boards using STM32CubeMX with Simulink.
Navigate to Pinout & Configuration > Connectivity > SPI#
Verify that these settings meet the requirements of your application.
Note
The following are the limitations for SPI block:
Number of bytes of data to be sent to the transmit block should be less than the FIFO length.
On running SPI Controller Transfer block in Monitor & Tune, you might observe the junk data. To resolve, reconnect and start Monitor & Tune.
If SPI Controller Transfer block is used in a model don’t use the SPI Transmit and SPI Receive blocks for the same module.
Avoid using same modules of SPI in multiple tasks, which can lead to issues.
SPI blocks do not support Master Receive Only, Slave Receive Only, Master Transmit Only, and Slave Transmit only for SPI mode configuration in STM32CubeMX file.
Examples
Ports
Input
Output
Parameters
Extended Capabilities
Version History
Introduced in R2023a