Skip to main content

I2C WRITE

Syntax​

I2C WRITE <addr> <reg> <val> [<val> ...]

Description​

Writes one or more bytes to a register of an I2C component. All numbers are hexadecimal. Up to 16 bytes can be written in one command. I2C transactions can add noise to the data of a running acquisition; prefer to write while acquisition is stopped.

Parameters​

ParameterTypeRangeDescription
<addr>hex0x00–0x7F7-bit I2C address (for example 0x48).
<reg>hex0x00–0xFFRegister address.
<val>hex0x00–0xFFBytes to write (1 to 16).

Response​

OK I2C WRITE bytes=<n>

Errors​

ReplyCondition
ERR I2C WRITE i2c_errorThe component did not acknowledge, or the transaction failed.
ERR I2C WRITE bad_argMissing or malformed arguments, or address out of range.

Example​

Write two bytes to register 0x10 of the component at address 0x48:

i2c_write.py
from hmcls_udp import Board

board = Board("192.168.1.11")
reply = board.request("I2C WRITE 0x48 0x10 0x01 0xFF")
print("bytes written:", reply["bytes"])