I2C Controller Read
Read data from I2C peripheral device or I2C peripheral device register
Simulink Support Package for Arduino Hardware / Common
Read serial data from an I2C peripheral. Using this block, you can also read data from a specific register on the I2C peripheral device.
For more information on I2C Communication, refer to I2C Read/Write.
Click View pin map to open the Arduino Pin Mapping table .
To know how to assign pins for the block, see Pin Mapping for Arduino Timer Independent Blocks.
Data — Output port to read data from the I2C peripheral device
Output port to read data from an I2C peripheral device. The size of the data that the port emits is based on the Data size (N) parameter.
Status — Status of the read operation
Output port to display error status. For more information, see Output error status.
This port appears only when you select the Output error status parameter.
I2C Module — Specific module used for I2C communication
0 (default) |
Select the specific module on the board that you are using.
Peripheral address — I2C peripheral device address
10 (default) | scalar
Enter the I2C peripheral device address from which you want to read data. You can specify this address in hexadecimal format hex2dec(), for example, hex2dec(‘10').
Peripheral byte order — Byte order supported by the I2C peripheral device
BigEndian (default) |
Select the byte ordering that your I2C peripheral supports.
The two byte ordering options are:
BigEndian— The most significant byte is read first over the I2C bus. This option is the default option.
LittleEndian— The least significant byte is read first over the I2C bus.
Enable register address — Option to enable reading from the register on I2C peripheral register
on (default) |
Select this check box to enable reading data from a specific register on the I2C peripheral device.
When you clear this parameter, the Send NACK at the end of data transfer and Remove stop bit at the end of data transfer parameters are displayed. Using these parameters, you can modify the read operation according to your requirements.
Peripheral register address — I2C peripheral device register address to read data
0 (default) | scalar
Enter the peripheral device register address from which you want to read the data.
Specify this address as an integer or in hexadecimal format by using
hex2dec(), for example, hex2dec(‘10’).
This parameter is enabled only when you select the Enable register access parameter.
Data type — Data type to read from I2C peripheral device
uint8 (default) |
Select the data type to read from I2C peripheral device.
Data size (N) — Data size to read from the I2C peripheral device
1 (default) | scalar
Enter the data size that you want to read from the I2C peripheral device for the selected data type.
Output error status — Option to display the error status during data transmission
off (default) | on
Select this option to display the error status during data transmission.
When you select the Output error status parameter, the block
configures an output port. The port on the block is labeled as
Status, indicating that the block outputs the status of the read
operation at the output port.
The block outputs the status as a
uint8 value. Each value
corresponds to a data transfer status.
Sample time — Frequency at which block reads data
0.1 (default) | scalar
Specify how often this block reads the data from the I2C peripheral. Enter a value greater than zero.
Introduced in R2015a