AnsweredAssumed Answered

Using I2C to read and write EEPROM

Question asked by Andy Berger on Feb 11, 2019
Latest reply on Feb 13, 2019 by Andy Berger

I am trying to use the Kinetis SDK v2.3 with a TWR-K64F to read and write a 16kBit serial EEPROM (Microchip 24LC16B). Specifically, I am using the i2c_polling_b2b_transfer_master example and have simply changed the 7-bit slave address to that of the EEPROM (in this case, 0x50, which is just the control code (0b1010, as specified in the datasheet), plus a page address of 000).

 

I also specify

uint8_t deviceAddress = 0x00U;

 

Otherwise, I use the example code as-is.

 

The semihosting console output from running this code is:

I2C board2board polling example -- Master transfer.
Master will send data : 0x 0 0x 1 0x 2 0x 3 0x 4 0x 5 0x 6 0x 7
0x 8 0x 9 0x a 0x b 0x c 0x d 0x e 0x f
0x10 0x11 0x12 0x13 0x14 0x15 0x16 0x17
0x18 0x19 0x1a 0x1b 0x1c 0x1d 0x1e 0x1f

 

Receive sent data from slave :
0x1f 0x10 0x11 0x12 0x13 0x14 0x15 0x16
0x17 0x18 0x19 0x1a 0x1b 0x1c 0x1d 0x1e
0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff
0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff


Error occured in the transfer !

End of I2C example .

I've tried to step through the code in debug mode, but it's very hard to tell where things are going wrong. Is there any documentation of the I2C API that demonstrates the state machine that is implemented?

Outcomes