Recovering I2C on SDA lockup

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Not applicable
Hi,

I am using the XMC1100 as a slave node. Occasionally I get communication glitches where the XMC1100 continues to hold the SDA low. I have tried toggling SCL until SDA returns to high but the SDA never goes high again.

Can the XMC slave be manually clocked by the master to restore the SDA to high logic level like lots of other I2C devices or does the state machine not allow this?

Is there a reset to restore the SDA level without restarting the MCU?

Thanks,

Joe
0 Likes
2 Replies
chismo
Employee
Employee
First like received
Hello Joe,

I would suggest the following recovery sequence for the I2C slave:

/* Disable SDA and SCL output pin functions */
XMC_GPIO_SetMode(SCL_PIN, XMC_GPIO_MODE_OUTPUT_PUSH_PULL);
XMC_GPIO_SetMode(SDA_PIN, XMC_GPIO_MODE_OUTPUT_PUSH_PULL);
/* Flush the contents of the FIFO */
XMC_USIC_CH_TXFIFO_Flush(I2C_CH_NUM);
XMC_USIC_CH_RXFIFO_Flush(I2C_CH_NUM);
/* Invalidate the internal transmit buffer */
XMC_USIC_CH_SetTransmitBufferStatus(I2C_CH_NUM, XMC_USIC_CH_TBUF_STATUS_SET_IDLE);
/* Re-enable the SDA and SCL output pin functions following the recovery sequence */
XMC_GPIO_SetMode(SCL_PIN, XMC_GPIO_MODE_OUTPUT_OPEN_DRAIN_ALT2);
XMC_GPIO_SetMode(SDA_PIN, XMC_GPIO_MODE_OUTPUT_OPEN_DRAIN_ALT2);


Regards,
Min Wei
0 Likes
Not applicable
Thanks for the response.

That looks like what is suggested for the SCL lockup in the errata. If SDA is also handled this way, the errata should be updated.

That said, I am trying to understand if the master can attempt to manually send clock signals to recover as well. Is this possible?

Otherwise I have to figure out how the slave is supposed to know when to call this recovery logic.

Thanks,

Joe
0 Likes