Skip to content

Using 12c to write to a 16 bit register #74

Answered by MrYsLab
boonsiong123 asked this question in Q&A
Discussion options

You must be logged in to vote

Thanks for the question. This is accomplished by converting the 16-bit value into two 8-bit values, an MSB and an LSB value. These values are written to the i2c device register.

This article explains how to split a 16-bit value into msb and lsb values using Python.

If you look at line 491 of Rob Tilaart's Arduino library for the device, you will see an example in an Arduino library.

Here is how this might be expressed in Telemetrix:

def write_16_bit_i2c(register, value):
    """
    Write a 16 value to an i2c register
    :param register: i2c register
    :param value: 16 bit value
    :return: None
    """
    msb = value >> 8
    lsb = value & 0xff
    my_board.i2c_write( i2c_device_add…

Replies: 2 comments 4 replies

Comment options

You must be logged in to vote
3 replies
@MrYsLab
Comment options

Answer selected by MrYsLab
@Pi3rr3-aprisium
Comment options

@MrYsLab
Comment options

Comment options

You must be logged in to vote
1 reply
@boonsiong123
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants