AnsweredAssumed Answered

problem about I2C read sequence

Question asked by 李 珍 on Apr 19, 2018
Latest reply on Apr 24, 2018 by Jing Pan

when i used the demo code of I2C read function in thetext named "I2C_read_access _valu_ Transfer" ,the code cannot be run correctly,it alwals stoped in the code of while((!nakFlag) && (!completionFlag)),therefor, I can write datas to the slave correct,so i am sure the slave address and the configuration of the I2C is correct.and now, I don't know how to solve the problem,and read datas from the slave address.
here is the demo code and the read sequence of my slave device:
demo code of I2C read function :
static bool I2C_ReadAccelRegs(I2C_Type *base, uint8_t device_addr, uint8_t reg_addr, uint8_t *rxBuff, uint32_t rxSize)
i2c_master_transfer_t masterXfer;
memset(&masterXfer, 0, sizeof(masterXfer));
masterXfer.slaveAddress = device_addr;
masterXfer.direction = kI2C_Read;
masterXfer.subaddress = reg_addr;
masterXfer.subaddressSize = 1; = rxBuff;
masterXfer.dataSize = rxSize;
masterXfer.flags = kI2C_TransferDefaultFlag;
/* direction=write : start+device_write;cmdbuff;xBuff; */
/* direction=recive : start+device_write;cmdbuff;repeatStart+device_read;xBuff; */
I2C_MasterTransferNonBlocking(BOARD_ACCEL_I2C_BASEADDR, &g_m_handle, &masterXfer);
/* wait for transfer completed. */
while ((!nakFlag) && (!completionFlag))
nakFlag = false;
if (completionFlag == true)
completionFlag = false;
return true;
return false;
the read sequence of my slave device: