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

TWI reading the same data from registers

Hi,

The problem statement mentioned below.

What we are trying to do is Read Light value from the MAX44009 sensor on the TWI interface.

Looking at the data sheet for the MAX44009, the device freezes updates of the light value (registers 0x03 and 0x04) during an I2C action and releases them for update on seeing an I2C STOP. The data sheet suggests

If the user wants to read both the Lux High-Byte register 0x03 and Lux Low-Byte register 0x04, then the master should not send a STOP command between the reads of the two registers. Instead a Repeated START command should be used. This ensures accurate data is obtained from the I2C registers (by disabling internal updates during the read process).

 We want to use  the function nrf_drv_twi_xfer() with the flags NRF_DRV_TWI_XFER_TXRX. Is it a right approach ? . How this operation works? one read, one write followed by another read and write? or two continuous reads and two continuous writes?. Please suggest us a way to get updated value from both the registers. also Please suggest the correct flags or alternate API to achieve this functionality.

Parents
  • Hello,

    Sorry for the late reply. 

    It looks like what you are looking for is not a standard NRF_DRV_TWI_XFER_TXRX, but rather a NRF_DRV_TWI_XFER_TXRXTXRX (with no STOP signal in between). This is not supported by the driver by default.

    I can't find any mentions in the drivers regarding NO_STOP flags in TWI RX mode, only in TX, so I am not sure whether it is possible, although it looks like the TWIM peripheral supports this.

    Maybe you can give it a go to use the TWI registeres as described in the link above to see if you can get the behavior that the sensor expects.

Reply
  • Hello,

    Sorry for the late reply. 

    It looks like what you are looking for is not a standard NRF_DRV_TWI_XFER_TXRX, but rather a NRF_DRV_TWI_XFER_TXRXTXRX (with no STOP signal in between). This is not supported by the driver by default.

    I can't find any mentions in the drivers regarding NO_STOP flags in TWI RX mode, only in TX, so I am not sure whether it is possible, although it looks like the TWIM peripheral supports this.

    Maybe you can give it a go to use the TWI registeres as described in the link above to see if you can get the behavior that the sensor expects.

Children
Related