diff --git a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC176X/i2c_api.c b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC176X/i2c_api.c index c7eea7cee7..6da6c7d1a7 100644 --- a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC176X/i2c_api.c +++ b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC176X/i2c_api.c @@ -350,11 +350,18 @@ int i2c_slave_read(i2c_t *obj, char *data, int length) { count++; } while (((status == 0x80) || (status == 0x90) || (status == 0x060) || (status == 0x70)) && (count < length)); - + + // Clear old status and wait for Serial Interrupt. + i2c_clear_SI(obj); + i2c_wait_SI(obj); + + // Obtain new status. (See Image-2) + status = i2c_status(obj); + if(status != 0xA0) { i2c_stop(obj); } - + i2c_clear_SI(obj); return count;