Skip to content

Commit 9ee1fc9

Browse files
author
Bogdan Marinescu
committed
[KL25Z] Fix I2C issue related to the silicon errata.
Makes a difference when running the I2C EEPROM test at 400KHz, which has a 100% success rate after this change.
1 parent 6c05438 commit 9ee1fc9

File tree

1 file changed

+8
-0
lines changed
  • libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KL25Z

1 file changed

+8
-0
lines changed

libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KL25Z/i2c_api.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,18 @@ void i2c_init(i2c_t *obj, PinName sda, PinName scl) {
8989
}
9090

9191
int i2c_start(i2c_t *obj) {
92+
uint8_t temp;
93+
volatile int i;
9294
// if we are in the middle of a transaction
9395
// activate the repeat_start flag
9496
if (obj->i2c->S & I2C_S_BUSY_MASK) {
97+
// KL25Z errata sheet: repeat start cannot be generated if the
98+
// I2Cx_F[MULT] field is set to a non-zero value
99+
temp = obj->i2c->F >> 6;
100+
obj->i2c->F &= 0x3F;
95101
obj->i2c->C1 |= 0x04;
102+
for (i = 0; i < 100; i ++) __NOP();
103+
obj->i2c->F |= temp << 6;
96104
} else {
97105
obj->i2c->C1 |= I2C_C1_MST_MASK;
98106
obj->i2c->C1 |= I2C_C1_TX_MASK;

0 commit comments

Comments
 (0)