This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

i2c_burst_write difference nrf52 and nrf91 series

Dear All,

I'm using Zephyr to configure a nrf9160 as I2C master and the OPT3002 light sensor as I2C slave.
The OPT3002 has a 16bit configuration register, which I need to write to.
For this I use i2c_burst_write(), which works fine on the nrf52 series (nrf52840 & nrf52833), with I2C_0. I can write to the register and read correct light intensity values.
However, on the nrf9160, with I2C_2, I can read the registers fine, but not write to them properly. This means I cannot get the sensor out of power down mode and therefore not read any sensor values.

Now I have seen this issue with burst_write and I should probably use another i2c write function.
However, I would like to know what the difference is between the nrf52 and nrf9160, that causes this issue to only happen on the nrf9160.

Do you have any idea what causes this difference?

Kind regards,
Maaike

Parents Reply Children
  • I looked into this, and got a better overview of what's going on.

    When writing to a register, the following should appear on the SDA line:

    • Send start command
    • Send 7 bit start address + write bit
    • Send register address
    • Send data to be written to the register

    You are trying to write 0xC688 to the configuration register with address 0x01 of an I2C slave with address 0x88.

    What the nRF52840 does, based on the trace

    • Send start command
    • Send 7 bit start address (0x88) + write bit
    • Send register address (0x01)
    • Send data to be written to the register (0xC6 + 0x08)

    What the nRF9160 does, based on the trace

    • Send start command
    • Send 7 bit start address (0x88) + write bit
    • Send register address (0x01)
    • Send 7 bit start address (0x88) + write bit
      • This is where it differs from the nrf52, it splits the message up in two pieces
    • Send register address (0xC6)
    • Send data to be written to the register (0xC6 + 0x08)
      • This is why it fails, because this is not register 0x01
    • Send data (0x08)

    I suspect the issue is that for the nRF9160, the function i2c_nrfx_twim_transfer() does not concatenate the messages for some reason, and calls nrfx_twim_xfer() two times. I'm not sure why if this is the case.

    Could you try to do some debugging in the function  i2c_nrfx_twim_transfer(), both when the nRF52840 is used, as well as the nRF9160. Check if nrfx_twim_xfer() is called one or two times.

    By the way if  "nordic,nrf-twim" is set in the dts/overlay file, i2c_nrfx_twim.c will be used, and if  "nordic,nrf-twi" is set, i2c_nrfx_twi.c will be used

    Best regards,

    Simon

Related