I'm experiencing a problem using the LPI2C on my MIMXRT1160-EVK board. I'm using the non-blocking transfer functions to read and write data to an EEPROM memory. During my firmware initialization, I'm reading 628 bytes from this memory, and when the memory is connected to my EVK board, everything works fine.
The problem happens when I don't have this memory connected to my board. The LPI2C_MasterTransferNonBlocking gets stuck in fsl_lpi2c.c driver, in the while loop on line 1235 (SDK Version 2.16.0):
I've managed to replicate this problem in the SDK example (evkmimxrt1160_lpi2c_interrupt_b2b_transfer_master_cm7) by changing the transfer data size to more than 600 bytes (lines 134 and 164). As far as I understand, the non-blocking functions shouldn't get stuck in any part of the code, even if my I2C device is not there, or am I missing something here?
In my custom firmware, I've tried to read just 256 bytes instead of 628 bytes, and it works fine. Obviously, I'm not able to read any data from the memory, but the code doesn't get stuck and I'm able to handle the error myself in my application code.
Ok, the function might be non-blocking, but it's still getting stuck in the while loop.
First scenario: I2C device is connected, my MCU sends 600+ bytes in a single LPI2C_MasterTransferNonBlocking call, and everything works fine.
Second scenario: I2C device is not connected, my MCU tries to send 600+ bytes using LPI2C_MasterTransferNonBlocking, and it gets stuck in the while loop indefinitely.
How can we deal with the second scenario? Is this a bug in the LPI2C driver?
Hi,
Yes, it should be issue for this case, as code comments shown(LPI2C_TransferStateMachineSendCommand), 'The transmission commands will not exceed FIFO SIZE.(will improve)', ' /* Issue command to receive data. A single write to MTDR can issue read operation of 0xFFU + 1 byte of data at most, so when the dataSize is larger than 0x100U, push multiple read commands to MTDR until dataSize is reached. */'
It's better to add some workarouds(try times, time duration) to check if I2C is workable or not.
Hi,
'The problem happens when I don't have this memory connected to my board'
--> I assumed it should works well if the salve is always connected correctly before running the SW, and issue should be reproduced if remove the slave devices during that time.
We need to figure it out about the key points of 'LPI2C_MasterTransferNonBlocking', it is non blocking transfer function from Master to Slave.
But in your problem, issue happend in 'LPI2C_TransferStateMachineSendCommand' which depends on some logic steps(e.g, getFifoCount, compare RXsize) from Application level and was to deal with Send Command State yet, certainly it is not a non-blocking function when issue happen on the while() conditions.