Hi gordon,
Please tell me what the chip you are using? Give me the part number.
Now, take KL25 as an example, the stop code in KSDK is:
status_t I2C_MasterStop(I2C_Type *base)
{
status_t result = kStatus_Success;
uint16_t timeout = UINT16_MAX;
/* Issue the STOP command on the bus. */
base->C1 &= ~(I2C_C1_MST_MASK | I2C_C1_TX_MASK | I2C_C1_TXAK_MASK);
/* Wait until data transfer complete. */
while ((base->S & kI2C_BusBusyFlag) && (--timeout))
{
}
if (timeout == 0)
{
result = kStatus_I2C_Timeout;
}
return result;
}
Actually, you can check our SDK code, which can be download from this link:
Welcome | MCUXpresso SDK Builder
Have a great day,
Kerry
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------