I am using the LPI2C_MasterTransferNonBlocking API to control the I2C bus on a i.MX RT 1052 EVKB.
The API creates a complete bus transaction the first time (either read or write) and fails in subsequent calls. See the logic analyzer trace of a failed transaction, attached
The callback that is registered via the LPI2C_MasterTransferCreateHandle API is called on the first use of LPI2C_MasterTransferNonBlocking but not on the second, presumably because the bus transaction never completes.
If I substitute LPI2C_MasterTransferBlocking for LPI2C_MasterTransferNonBlocking in my code all works as expected.
I would like to use LPI2C_MasterTransferNonBlocking to implement an receive with a timeout.
Any help would be appreciated.
Hi David Polonsky
Could you share the code that you are using? I can see in the scope that you correctly set a start, read with address and then there isn't any response in the Bus, also no STOP, so it could be that the slave is not responding to the master.
Have you checked the code in the example code in of lpi2c_interrupt_b2b_transfer_master? there is implemented a communication where it writes and read from the slave.
Thanks you for your reply. Here is a snippet from the code where I set up the I2C receive. I currently have it commented currently as, as I posted, it does not work.
// lpi2c_master_transfer_t transfer;
// memset(&transfer, 0, sizeof(transfer));
// transfer.flags = kLPI2C_TransferDefaultFlag;
// transfer.slaveAddress = m_address;
// transfer.direction = kLPI2C_Read;
// transfer.subaddress = 1;
// transfer.subaddressSize = 1;
// transfer.data = in_data;
// transfer.dataSize = count;
// status_t status = LPI2C_MasterTransferNonBlocking(m_base, &m_handle, &transfer);
I have also tried: transfer.flags = kLPI2C_TransferDefaultFlag | kLPI2C_TransferRepeatedStartFlag;
m_base has been set to LPI2C1_BASE
m_handle is set by calling LPI2C_MasterTransferCreateHandle(m_base, &m_handle, lpi2c_master_callback, this);
Sorry for the delays. Regarding your configurations, did you "count" in datasize is considering the subaddress? is it also sent by the slave? please consider that your transfer will be
start + slaveaddress(w) + subAddress + repeated start + slaveaddress(r) + Rx data buffer + stop
So the slave has to consider the subaddress in the setup.