I2C read - repeated start needed?

Solution 1:

The i2c protocol works like this

WRITE:
  1. send START
  2. write slave address with last bit as WRITE ACCESS(0)
  3. write sub-address: this is usually the address of the register you what to write to; if not applicable skip to 4.
  4. write data
  5. send STOP

Each byte you write to the slave device should be answered with an ACK if the operation was successful.

READ:
  1. send START
  2. write slave address with last bit as WRITE ACCESS(0)
  3. write sub-address: this is usually the address of the register you what to read from
  4. send START (this is a second start condition - a restart)
  5. write slave address with last bit as READ ACCESS(1)
  6. read data
  7. send STOP

All write and read operations (except the last read) are answered with a ACK if successful.

So in the case of a restart you don't send a second Stop.

As far as the 0xFF read result is concerned, you need to check the datasheet of the device, but some will return this value if the data you are trying to read is not available, yet!

Hope this helps.

Solution 2:

I just had this issue and found the reason: if you receive FFh in reading all the time, you are missing the repeated start.