Skip to Content

I2C Write Block Description

This block supports the I2C peripheral interface in Mem Write mode. It is used to write data to a specific register or memory address inside a Slave device (such as a sensor or EEPROM memory). The block automatically sends the device address first, followed by the defined internal register address, and finally the actual input data.



I2C Write block

Table of Contents

Inputs

Input NameTypeDescription
Register addressuint8 / uint16The address of the register to which data is to be written. The input data type depends on the value of the Register address size parameter.
Write datauint8[ ]Data to be sent via the I2C interface. The size of the input depends on the value of the Write size parameter.

Outputs

Output NameTypeDescription
Statusuint8Transmission status. Returns:
1 transmission successful
0 transmission failed

Block Parameters

ParameterDescription
I2C NumberI2C module number (for a single MCU I2C, this should be set to 0)
Slave addressAddress of the slave device
ModeBlock operating mode
Register address sizeRegister address size:
I2C_MEMADD_SIZE_8BIT - 8-bit
I2C_MEMADD_SIZE_16BIT - 16-bit
Write sizeSize of the data to be written. Determines the amount of data sent from the Write Data input.
TimeoutHow long the system will wait for the block execution
Sample time [s]Function refresh rate


Block parameters for I2C

CubeMX Configuration for a Given MCU

The configuration for the interface can be found on the subpage CubeMX Configuration for a Given MCU.

See Also

Last updated on