I2C_MasterTransferAbort() Getting Hung During I2C Recovery on LPC55S69 Hello Team, I am currently working on an application using the LPC55S69. I have a sensor module that communicates with the LPC55S69 over the I2C interface. I am implementing an I2C recovery mechanism in which I call I2C_MasterTransferAbort() to abort an incomplete non-blocking I2C transfer. However, in some instances, this function appears to get stuck. I have added log messages before and after this function call. However, I can only see the log message printed before the call, and the message after the call is never printed. This indicates that the execution is getting stuck inside I2C_MasterTransferAbort(). Please refer to the logs below. The I2C interface being used is I2C5_MASTER. PRINTF("%s() -> CFG=0x%08lX, STAT=0x%08lX, MSTCTL=0x%08lX, MSTDAT=0x%08lX, INTSTAT=0x%08lX, INTENSET=0x%08lX, TIMEOUT=0x%08lX\r\n",
__func__,
(unsigned long)I2C5_MASTER->CFG,
(unsigned long)I2C5_MASTER->STAT,
(unsigned long)I2C5_MASTER->MSTCTL,
(unsigned long)I2C5_MASTER->MSTDAT,
(unsigned long)I2C5_MASTER->INTSTAT,
(unsigned long)I2C5_MASTER->INTENSET,
(unsigned long)I2C5_MASTER->TIMEOUT);
/* Capture interrupt state before cleanup. */
PRINTF("%s() -> FLEXCOMM5 IRQ enabled=%d, pending=%d\r\n",
__func__,
(int)NVIC_GetEnableIRQ(FLEXCOMM5_IRQn),
(int)NVIC_GetPendingIRQ(FLEXCOMM5_IRQn));
/* Abort the incomplete non-blocking I2C transfer. */
status_t abortStatus = I2C_MasterTransferAbort(I2C5_MASTER, &g_m_handle);
PRINTF("%s() -> I2C_MasterTransferAbort status=%d\r\n",
__func__,
(int)abortStatus); Observed log output: CFG=0x00000001, STAT=0x00000800, MSTCTL=0x00000002,
MSTDAT=0x00000055, INTSTAT=0x00000000,
INTENSET=0x03000051, TIMEOUT=0x0000FFFF
FLEXCOMM5 IRQ enabled=1, pending=0 As you can see from the above logs, the following message is never printed: I2C_MasterTransferAbort status One thing I noticed is that I2C_RETRY_TIMES is currently set to 0. Based on my investigation, I suspect that the execution is getting stuck inside I2C_PendingStatusWait(). Could someone please help me understand why I2C_MasterTransferAbort() works in some instances but gets stuck in others? In particular, I would like to understand what conditions could cause I2C_PendingStatusWait() to wait indefinitely and whether the I2C_RETRY_TIMES configuration has any impact on this behavior. Thank you. Regards, San 回复: I2C_MasterTransferAbort() Getting Hung During I2C Recovery on LPC55S69 Hi @sushmasan
Thank you for the information. Yes, I2C_RETRY_TIMES can affect this behavior. With I2C_RETRY_TIMES set to 0, I2C_PendingStatusWait() has no software retry limit and can continue waiting if the expected I2C status flag does not change. In your failing case, STAT = 0x00000800 indicates that MSTPENDING is not asserted at the time of recovery. Therefore, as a first test, please try setting I2C_RETRY_TIMES to a non-zero value to prevent an indefinite wait. Please note that this addresses the indefinite polling behavior, but it does not necessarily resolve the original reason why MSTPENDING remains deasserted. To investigate the root cause, please capture the SCL and SDA waveforms when the issue occurs.
BR
Harry 回复: I2C_MasterTransferAbort() Getting Hung During I2C Recovery on LPC55S69 Hi @Harry_Zhang , Thanks for your response. I forgot to provide an update. During the test, I intentionally disconnected the sensor from the I2C bus midway through the test to observe the system's behavior. I then reconnected the sensor, and this is when I captured the logs. Do you think this might be the reason why MSTPENDING is not asserted? Regards, San
View full article