This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

nRF52832 TWI implementation with 16-bit register addresses

We need to read/write to an I2C device that uses a 16-bit register addresses (Melexis MLX90632), and the nrf_drv_twi_tx() and nrf_drv_twi_rf() functions seem to be limited to 8-bit addresses.

How can we use the TWI module to read 16-bit addressed registers?

Thanks!

Parents
  • I had already reviewed all those links before I submitted my question.  They were not specific enough.

    I do mean "register address", not "device address".

    My question is very specifically about the nrf_drv_twi_tx() function.  An I2C read is a two-part process: (1) I2C write register address, (2) I2C read from that address.  So a nrf_drv_twi_tx() is followed by nrf_drv_twi_rx().

    The answer to my question is to break the register address into an array of uint8_t type and write the bytes sequentially.  So a register address of 0x1234 can be written as 2 bytes:

    uint8_t reg[] = {0x12, 0x34};  //decompose 16-bit address, MSB first
    err_code = nrf_drv_twi_tx(&m_twi, DVC_I2C_ADDR, reg, 2, false);

    This simple answer hopefully will help others who ask the same question about 16-bit and 32-bit register addressing using the nrf_drv_twi_tx() question.  

Reply
  • I had already reviewed all those links before I submitted my question.  They were not specific enough.

    I do mean "register address", not "device address".

    My question is very specifically about the nrf_drv_twi_tx() function.  An I2C read is a two-part process: (1) I2C write register address, (2) I2C read from that address.  So a nrf_drv_twi_tx() is followed by nrf_drv_twi_rx().

    The answer to my question is to break the register address into an array of uint8_t type and write the bytes sequentially.  So a register address of 0x1234 can be written as 2 bytes:

    uint8_t reg[] = {0x12, 0x34};  //decompose 16-bit address, MSB first
    err_code = nrf_drv_twi_tx(&m_twi, DVC_I2C_ADDR, reg, 2, false);

    This simple answer hopefully will help others who ask the same question about 16-bit and 32-bit register addressing using the nrf_drv_twi_tx() question.  

Children
No Data
Related