Migrate I2C Block Usage to STM32 Processor Based Library Block
When you migrate I2C 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 I2C Controller Read block and I2C Controller Write block to the STM32 processor library I2C Controller Read block and I2C Controller Write block:
Open the Simulink model in which you are migrating block usage.
From Configuration Parameters > Hardware Implementation > Target hardware resources > Group, select the I2C0 (default) resource. Note the pin selections for SCL (
D15
corresponds to external pinPB_8
) and SDA (D14
corresponds to external pinPB_9
).Change Hardware board selection to
STM32F4xx Based
. 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
I2C1
port serial clock (SCL) pin usage toPB8
and the serial data (SDA) pin usage toPB9
.In the Simulink model, replace the I2C Controller Read from the Nucleo library with a I2C Controller Read from the STM32F4xx Based Boards library or STM32F7xx Based Boards library.
View the block configuration parameters. Confirm that the I2C module selection is configured for the default I2C module which is
I2C1
. This setting matches the pin mapping that you assigned in the CubeMX configuration IOC file.