Read data from I2C peripheral device register
data = readRegister(___,
reads data in the form specified by
Read Data from I2C Peripheral Device Register
Connect to an I2C peripheral device on an NI™ USB-845x controller and read data from a register on it.
Connect to the NI USB-845x using its serial number. In this example, the NI USB-845x controller board that is connected to the computer has the serial
controller = ni845x("01F26E0A");
Connect to an I2C peripheral device on the controller board. In this example, the
peripheral has an address of
peripheral = device(controller,I2CAddress="0x48");
Read two bytes of data from register address 0.
data = readRegister(controller,0,2);
ans = 0 0
peripheral — I2C peripheral device
I2C peripheral device, specified as a
readRegister(peripheral,registerAddress) reads from a
register on the I2C peripheral device object
peripheral connected to
an Aardvark™ or NI USB-845x controller.
registerAddress — Register address
Register address to read from on the I2C peripheral device, specified as a number. Refer to the peripheral device documentation or data sheet for more information about valid register addresses.
readRegister(peripheral,0) reads from a register at
count — Number of values to read
1 (default) | numeric
Number of values to read from continuous registers starting at
registerAddress, specified as a positive
readRegister(peripheral,registerAddress,5) reads five
datatype — Size and format of each value
"uint8" (default) |
Size and format of each value, specified as a character vector or string scalar.
datatype determines the number of bytes to read for each value
and the interpretation of those bytes as a MATLAB® data
Introduced in R2023a