AnsweredAssumed Answered

imxrt master non-blocking transfer issue

Question asked by Anthony SIEGRIST on Jan 31, 2019
Latest reply on Apr 4, 2019 by Anthony SIEGRIST

Hello,

 

I use I2C drivers from SDK 2.5 and I have an issue with non-blocking transfer as a master. The callback is called before the end of the transfer and return the wrong status.

 

To write 34 bytes to an I2C EEPROM memory (microchip 24AA02), I make 5 I2C transfers. 4 times 8 bytes + 2 bytes. After each transfer the memory replies with a NAK until write cycle is done.

 

Step1: At first transfer of 8 bytes, the callback is called after the stop bit detection with status =  kStatus_Success.

Step2: At second transfer, the callback is called on NAK detection (before stop bit detection) with status =  kStatus_LPI2C_Nak.

Step3: After several retry with NAK response, the callback is called 4 bytes before the stop bit with status =  kStatus_Success.

Step 4: Step2 and Step3 are repeated for others 8 bytes transfers.

Step 5: Last transfer of 2 bytes, the callback is called without sending any data with status =  kStatus_Success instead of kStatus_LPI2C_Nak.

 

In step5, commands are written to the FIFO then the state machine wait for the stop bit detection. But because the stop bit of the previous transfer is detected after that this transfer has been initiated, the callback retuns the wrong status and the data are never transmitted.

I attached some capture of this issue. The blue trace is a GPIO that is set when the transfer is initiated and cleared when the callback is called.

 

 

Note: In LPI2C_RTOS_Transfer(), handle->async_status should be saved in status variable before unlocking the resource mutex. A task with higher priority may overwrite handle->async_status.

 

BR

Anthony

Outcomes