Skip to Content

I2C Read Block Description

This block supports the I2C peripheral interface in Mem Read mode. It is used to read data from a specific register or memory address of a Slave device. The block executes a complex sequence: it first sends the register address it wants to read from, then automatically restarts the bus (Repeated START) into read mode, and outputs the retrieved data to the block output.



I2C Read block

Table of Contents

Inputs

Input NameTypeDescription
Register addressuint8 / uint16The address of the register from which data is to be read. The input data type depends on the value of the Register address size parameter.

Outputs

Output NameTypeDescription
Statusuint8Transmission status. Returns:
1 transmission successful
0 transmission failed
Read data[ ]uint8[ ]Data received via the I2C interface. The size of the output depends on the value of the Read size parameter.

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
Read sizeSize of the data to be read. Determines the amount of data read from the RX 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