IIC 16 bit address pynq.lib.iic

Do you have a work around for IIC addresses larger than 8 bit as imx219 (RPI Cam V2) needs to be configured using 16bit addresses.

OverflowError Traceback (most recent call last)
in
----> 1 test.send(0x479B, 0x05, 8, 0)

/usr/local/share/pynq-venv/lib/python3.8/site-packages/pynq/lib/iic.py in send(self, address, data, length, option)
99
100 “”"
→ 101 sent = AxiIIC._lib.XIic_Send(
102 self._virtaddr, address, data, length, option)
103 if sent == 0:

OverflowError: integer 18331 does not fit ‘unsigned char’

Hi @JackBonnellDev,

I am not sure how familiar you are with IIC. The address in the send/receive is not the register address you are trying to write/read. It is the peripheral address, each IIC peripheral has one.

Then in the data argument you will add both the register and data you want to write.

You can check a discussion here

And an example of send here

What board are you targeting? As an alternative, you could use device tree overlays to insert the driver of the AXI IIC IP in Linux and then you should be able to open the i2c device and even use python-periphery

If you decide to go this route, I can give you more pointers.

Mario

Hello,

Do you have a work around for IIC addresses larger than 8 bit as imx219 (RPI Cam V2) needs to be configured using 16bit addresses.

I believe there is confusion in your understanding of how to use an i2c device with internal registers.

IMX219 uses 16 bits addresses for accessing it’s internal memory. However, it’s i2c address is still 8 bits.

Accessing a memory on i2c is done as such (pseudo-code):
Writing a register: I2C_write(device_address, [reg_addr_high, reg_addr_low, data0, data1, ...]);
Reading a register: I2C_write(device_address, [reg_addr_high, reg_addr_low]); I2C_read(device_address);

It is detailed page 17 or 23 of the IMX219, with plenty of chronograms.

Kind regards,
Marin Mikaël

1 Like

Thanks i’ve taken your advice but im still struggling to get it to run any ideas?

Hi,

it seems that your device is not answering.
it could be for different reasons.
Things to do to debug this situation:

  1. Try with all addresses (protip: use try - except)
  2. Use a logic analyzer to see what’s going on on the wire

Kind regards,
Marin Mikaël