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

TWI and 11-bit I2C slave address devices

Hi. We are attempting to use the Infineon XMC1202 LED shield with our NRF52 device. The XMC1202 has an I2C address of 0x15E, instead of the traditional 7 bit address. We have been using the simple non-blocking TWI implementation to date. We can fake out the non-blocking TWI implementation for write commands. However for I2C reads, it is not clear how to pass in an address greater than 8 bits. Is this possible? Please advise.

  • Hi,

    From the user manual of the shield I can see the following:

    The RGB LED Shield’s I2C address is a 10-bit address and is pre-configured to be 0x15E. To address it, the master will send 2 bytes of address:

    • The first 7 bits of the first byte are 11110XX, of which XX are the two most significant bytes of the 10-bit address. The 8th bit determines the read or write direction of the data transfer.
    • The second byte is the lower 8-bits of the address.

    This page describes the procedure for interfacing 10-bit addressable devices. If you setup a RXTX transfer where you write the second byte of the address before switching to TX mode, it should work. This is also described in section 3.1.11 in the I2C-bus specification and user manual.

    Best regards,

    Jørgen

  • Hi Jorgen. Thanks for the reply. I used the twi_scanner example to implement the TXRX suggestion. Code snippet below. nrf_drv_twi_xfer_desc_t xfer;

    tx_buf[0] = lowerAddress;
    tx_buf[1] = Command;  
           
    xfer.type = NRF_DRV_TWI_XFER_TXRX;
    xfer.address = upperAddress;
    xfer.primary_length   = sizeof(tx_buf);
    xfer.secondary_length = sizeof(rx);
    xfer.p_primary_buf    = tx_buf;
    xfer.p_secondary_buf  = rx;
    err_code = nrf_drv_twi_xfer(twi_instance, &xfer, NRF_DRV_TWI_FLAG_NO_XFER_EVT_HANDLER);
    

    This code works. I can read from the XMC1202. However, once this code is integrated into our platform that uses a soft device, the read fails. Specifically, the nrf_drv_twi_xfer() returns NRF_SUCCESS, but the rx_buffer is not populated. To test this theory, we added TWI to the ble_app_blinky example in ble_peripheral. Again, the read returns success, but the rx_buffer is not populated. Is there an issue with using this function with a softdevice?

  • Please disregard. Looks like we needed to enable TWI0_USE_EASY_DMA in our config file. That fixed the issue. Thanks again.

Related