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

TWI read with 32 bits register address return all zeros

Hi all,

Using the nrf52832 TWI, I am trying to interract with a sensor through I2C.

On the same board, I am successfully able to exchange data with an accelerometer (8bit register adress) using I2C, but when I am trying to exchange with the other devices which uses 32 bits adress, the TWI_perform only returns 0 on the ret_buffer. Though on the oscilloscope I can see that the device is responding normally to my request.

Here's my function : 

uint32_t igo_hal_i2c_buf_read(uint8_t i2c_id, uint8_t* buf, uint32_t len, uint8_t* ret_buf)
{
   nrf_twi_mngr_transfer_t transfers[2];

   transfers[0].p_data = buf;
   transfers[0].length = 4;
   transfers[0].operation = NRF_TWI_MNGR_WRITE_OP(i2c_id);
   transfers[0].flags = NRF_TWI_MNGR_NO_STOP;

   transfers[1].p_data = ret_buf;
   transfers[1].length = len;
   transfers[1].operation = NRF_TWI_MNGR_READ_OP(i2c_id);
   transfers[1].flags = 0;

   twi_perform(&g_twi_bus_config[CONFIG_WWR_TWI_BUS], transfers, ARRAY_SIZE(transfers))
}

Please note that twi_perform does return NRF_SUCCESS!

Do you have any idea why the ret_buffer is always NULL while the I2C exchange is ok as I can decode it on my oscilloscope?

Thanks in advance!

Sylvain

Related