Migrate SPI Block Usage to STM32 Processor Based Library Block
When you migrate SPI block usage in STMicroelectronics hardware board models from using Simulink Coder support package blocks to using Embedded Coder support package blocks, there is a workflow you should use. This table lists the blocks that should be migrated with this workflow.
Migrate Block Usage
Migrate from Blocks in Simulink Coder Support Package for STMicroelectronics Nucleo Boards Library | Migrate to Blocks in Embedded Coder Support Package for STMicroelectronics STM32 Processor Library |
---|---|
To migrate your model from using these blocks to using the corresponding blocks in an STM32Fxx Based Board block library, follow these steps. These example steps show the process for migrating usage from the Nucleo library SPI Register Read block and SPI Register Write block to the STM32 processor library SPI Receive block and SPI Transmit block:
Open the Simulink model in which you are migrating block usage.
From Configuration Parameters > Hardware Implementation > Target hardware resources > Group, select the SPI0 (default) resource. Note the pin selections for SDO (
D11
corresponds to external pinPA_7
), SDI (D12
corresponds to external pinPA_6
), and SCK (D13
corresponds to external pinPA_5
).The pin selection for the CS (
D7
corresponds to external pinPF_13
) is selected from the SPI Register Read block and SPI Register Write block parameters.D7
is connected as shown. To get more info on SPI modes, see Support SPI Communication.Mode
Clock Polarity (CPOL)
Clock Phase (CPHA)
0
0
0
1
0
1
2
1
0
3
1
1
Change Hardware board selection to
STM32F7xx Based (Double Precision)
. After the dialog box updates to match this selection, From Target hardware resources > Build options, use the Browse or Create buttons to select anSTM32CubMX project file
.To open the STM32 CubeMX configuration software and configure pin selections, click the Launch button.
In the STM32 CubeMX configuration software, configure the
SPI1
port options.In the STM32 CubeMX configuration software, configure the
SPI1_SCK
(PA5
),SPI1_MISO
(PA6
),SPI1_MOSI
(PA7
), andGPIO_Output
(PF13
) pin usage.In the Simulink model, replace the SPI Register Read block and SPI Register Write block from the Nucleo library with a SPI Receive block and SPI Transmit block from the STM32F4xx Based Boards library or STM32F7xx Based Boards library.
View the block configuration parameters. Confirm that the SPI chip select features are setup as shown. This setting matches the options that you assigned in the CubeMX configuration IOC file.