Write data to an I2C slave device or an I2C slave device register
Simulink Support Package for Arduino Hardware / Common
Write data to an I2C device on the Arduino® hardware. Using this block, you can also write data to a specific register on the I2C slave.
Data— Input port to write data to I2C slave device
The input port write data to the I2C slave device or I2C slave device register.
I2C Module— Specific module used for I2C communication
Select the specific module on the board that you are using.
Slave address— Address of I2C slave device
Enter the I2C slave device address to which you want to write the data. The I2C slave device address is a 7-bit address.
Specify this address as an integer or in hexadecimal format by using
hex2dec(), for example hex2dec(‘20’).
Slave byte order— Byte order supported by the I2C slave device
Select the byte ordering that your I2C slave supports, to write the data.
The two byte ordering options are:
Big Endian — The most significant byte is written first over the I2C bus. This option is the default option.
Little Endian — The least significant byte is written first over the I2C bus.
Enable register access— Option to enable writing to the register on I2C slave device
Select this check box to write data to a specific I2C slave register.
When you clear this parameter, the Remove stop bit at the end of data transfer parameter is displayed. Using this parameter, you can modify the write operation according to your requirements. For more information, Support I2C Communication
Remove stop bit at the end of data transfer— Option to remove STOP bit at the end of data transfer
When you clear this parameter, the block sends a STOP condition. This condition indicates that the block has terminated the data transmission and the I2C bus is free for any other I2C master block to initiate the read/write operation.
When you select this parameter, the block sends another START condition followed by an address and read/write bit. The block sends any number of start conditions recursively. Such a repeated START condition allows write operations to the slave devices without releasing the bus. No other master block interrupts the operation.
This parameter appears only when you clear the Enable register access parameter.
Slave register address— I2C slave device register address
Enter the slave device register address to which you want to write the data.
This parameter is enabled only when you select the Enable register access parameter.
Output error status— Option to display output error status
Select this option to display the output error status. When you select this
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 write
operation at the output port.
The block outputs the status as a
uint8 value. Each value
corresponds to a data transfer status.
|Status value||Status description|