I2C Controller Read
R2026bI2C Controller Read block
To add a block to a model, double-click the canvas and start typing the block name. Then, select the block from the list.
Libraries:
NVIDIA Jetson and NVIDIA DRIVE /
Communication
Description
Add-On Required: This feature requires the MATLAB Coder Support Package for NVIDIA Jetson and NVIDIA DRIVE Platforms add-on.
The I2C Controller Read block reads from an I2C peripheral device connected to an NVIDIA® Jetson™ hardware board.
Examples
Communicate with EEPROM Device From NVIDIA Jetson Hardware
Read from and write to an EEPROM device by using I2C communication from NVIDIA Jetson hardware.
- Since R2026b
- Open Live Script
Ports
Output
Data received from device, returned as a vector or scalar. The Data type and Data size (N) parameters determine the data type and size of the vector, respectively.
Transmission status, returned as a scalar. If the transmission is
successful, the block outputs 0. If
the transmission generates an error, the block outputs 8.
Dependencies
To enable this port, enable Output error status.
Data Types: uint8
Parameters
To edit block parameters interactively, use the Property Inspector. From the Simulink® Toolstrip, on the Simulation tab, in the Prepare gallery, select Property Inspector.
Hardware board to deploy the model to.
Programmatic Use
To set the block parameter value programmatically, use
the set_param (Simulink) function.
To get the block parameter value
programmatically, use the get_param (Simulink) function.
| Parameter: | Board |
| Values: |
"NVIDIA Jetson Orin Nano Developer Kit"
(default) |
"NVIDIA Jetson Nano Developer Kit"
|
"NVIDIA Jetson Orin NX Developer Kit"
|
"NVIDIA Jetson Xavier NX Developer Kit"
|
"NVIDIA Jetson AGX Xavier Developer Kit"
|
"NVIDIA Jetson AGX Orin Developer Kit"
|
"NVIDIA Jetson TX2 Developer Kit"
|
Example:
get_param(gcb,"Board")
I2C module to use on the board.
The setting for the Board parameter determines the available settings for this parameter and its programmatic parameter settings. This table shows the available I2C Module parameter settings and programmatic parameter names for each board:
| Board Parameter Setting | Available I2C Module Parameter Settings | Programmatic Parameter Name |
|
| I2CModule_1_7 |
|
| I2CModule_0_1 |
|
| I2CModule_1_8 |
Programmatic Use
To set the block parameter value programmatically, use
the set_param (Simulink) function.
To get the block parameter value
programmatically, use the get_param (Simulink) function.
| Parameter: | I2CModule_1_7 |
| Values: |
"7"
(default) |
"1"
|
Example:
get_param(gcb,"I2CModule_1_7")
| Parameter: | I2CModule_0_1 |
| Values: |
"0"
(default) |
"1"
|
Example:
get_param(gcb,"I2CModule_0_1")
| Parameter: | I2CModule_1_8 |
| Values: |
"8"
(default) |
"1"
|
Example:
get_param(gcb,"I2CModule_1_8")
Address of the peripheral device on the I2C module.
Tips
To obtain the device address, use the scanI2CBus
function. For example, for a live connection object named hwObj,
enter:
addresses = scanI2CBus(hwObj);
addresses{:}ans =
struct with fields:
Bus: 'i2c-1'
Devices: {'74'}
ans =
struct with fields:
Bus: 'i2c-8'
Devices: {'74'}The function returns addresses in the hexadecimal format. Convert the address to
decimal format by using the hex2dec function. For example, to
connect to the device at hexadecimal address 74, set
Peripheral address to hex2dec("74").
Programmatic Use
To set the block parameter value programmatically, use
the set_param (Simulink) function.
To get the block parameter value
programmatically, use the get_param (Simulink) function.
| Parameter: | SubAddress |
| Values: |
"10"
(default) | positive integer in quotes |
Example: set_param(gcb,SubAddress="116")
Example:
set_param(gcb,SubAddress=string(hex2dec("74"))) sets the address
to the hexadecimal value 74.
Order in which to transmit bytes between the Jetson board and the peripheral device.
Programmatic Use
To set the block parameter value programmatically, use
the set_param (Simulink) function.
To get the block parameter value
programmatically, use the get_param (Simulink) function.
| Parameter: | SubByteOrder |
| Values: |
"BigEndian"
(default) |
"LittleEndian"
|
Example:
set_param(gcb,SubByteOrder="LittleEndian")
Select this parameter to specify the register to read from on the device.
Programmatic Use
To set the block parameter value programmatically, use
the set_param (Simulink) function.
To get the block parameter value
programmatically, use the get_param (Simulink) function.
| Parameter: | RegisterAddressMode |
| Values: | "on" (default) | "off" |
Example: get_param(gcb,"RegisterAddressMode")
Register address that the block reads from on the device, specified as a nonnegative integer scalar or a 2-element vector. Each element must be between 0 and 255.
For devices that use 1-byte register addressing, specify the register address as a scalar. For devices that use 2-byte register addressing, specify the register address as a 2-element vector, where each element represents one byte of the address.
Dependencies
To enable this parameter, select Enable register access.
Programmatic Use
To set the block parameter value programmatically, use
the set_param (Simulink) function.
To get the block parameter value
programmatically, use the get_param (Simulink) function.
| Parameter: | RegisterAddress |
| Values: | "0" (default) | nonnegative integer or 2-element vector in quotes |
Example: set_param(gcb,"RegisterAddress","7")
Example: set_param(gcb,"RegisterAddress","[1 2]")
Data type of the output signal.
Programmatic Use
To set the block parameter value programmatically, use
the set_param (Simulink) function.
To get the block parameter value
programmatically, use the get_param (Simulink) function.
| Parameter: | SubDataType |
| Values: | "uint8" (default) | "int8" | "int16" | "uint16" | "int32" | "uint32" | "single" | "double" |
Example: set_param(gcb,SubDataType="uint16")
Size of the data that the block reads from the I2C device at each time step. The block reads N elements of the data type specified by the Data type parameter from the device.
Programmatic Use
To set the block parameter value programmatically, use
the set_param (Simulink) function.
To get the block parameter value
programmatically, use the get_param (Simulink) function.
| Parameter: | DataLength |
| Values: | "1" (default) | positive integer in quotes |
Example: set_param(gcb,DataLength="3")
Select this parameter to output the error status of the data transfer.
Programmatic Use
To set the block parameter value programmatically, use
the set_param (Simulink) function.
To get the block parameter value
programmatically, use the get_param (Simulink) function.
| Parameter: | OutputStatus |
| Values: | "off" (default) | "on" |
Example: get_param(gcb,"OutputStatus")
Sample time, in seconds, at which the block reads data from the I2C device. If
Sample Time is -1, Simulink automatically chooses a sample time for the block.
Programmatic Use
To set the block parameter value programmatically, use
the set_param (Simulink) function.
To get the block parameter value
programmatically, use the get_param (Simulink) function.
| Parameter: | SampleTime |
| Values: | "-1" (default) | numeric scalar in quotes |
Example: get_param(gcb,"SampleTime")
Extended Capabilities
C/C++ Code Generation
Generate C and C++ code using Simulink® Coder™.
Version History
Introduced in R2026b
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Seleccione un país/idioma
Seleccione un país/idioma para obtener contenido traducido, si está disponible, y ver eventos y ofertas de productos y servicios locales. Según su ubicación geográfica, recomendamos que seleccione: .
También puede seleccionar uno de estos países/idiomas:
Cómo obtener el mejor rendimiento
Seleccione China (en idioma chino o inglés) para obtener el mejor rendimiento. Los sitios web de otros países no están optimizados para ser accedidos desde su ubicación geográfica.
América
- América Latina (Español)
- Canada (English)
- United States (English)
Europa
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
