Write data to I2C peripheral device register
Write Data to I2C Peripheral Device Register
Connect to an I2C peripheral device on an NI™ USB-845x controller and write data to 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");
Write the value 10 to the register at address 1 as
peripheral — I2C peripheral device
I2C peripheral device, specified as a
writeRegister(peripheral,registerAddress,data) writes to
a register on the I2C peripheral device object
to an Aardvark™ or NI USB-845x controller.
registerAddress — Register address
Register address to write to 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.
writeRegister(peripheral,1,data) writes to a register at
data — Data to write
numeric | character vector | string scalar
Data to write to the register of the I2C peripheral device, specified as a row
N) or column (
N-by-1) vector of numeric
values or as a character vector or string scalar of
writeRegister(peripheral,registerAddress,5) writes the
value 5 to a register.
datatype — Size and format of each value
"uint8" (default) |
Size and format of each value, specified as a character vector or string.
datatype determines the number of bytes to write for each value
and the interpretation of those bytes as a MATLAB® data type. For ASCII text, you can specify
writes data to a register as
Introduced in R2023a