Reputation: 21
I have a doubt regarding read operation in I2C, bit banging. The protocol which I am following for read as below: Start-slave address with write-ack-register loc-ack-stop. ...... Start-slave address with read-ack-read data-stop. I am reading data as FFh which is wrong. My doubt is, before sending the another start, do in need to send stop or can continue the another start for reading data without stop, which actually is a repeated start. Does sending a stop bit or not makes any difference. Also can someone tell what can be the possible reason if data read is FFh. But I can guarantee that write operation is successful, after seeing the scope shot. Please guide me.
Thanks
Upvotes: 2
Views: 13859
Reputation: 11
I just had this issue and found the reason: if you receive FFh in reading all the time, you are missing the repeated start.
Upvotes: 1
Reputation: 4961
The i2c protocol works like this
WRITE:
Each byte you write to the slave device should be answered with an ACK if the operation was successful.
READ:
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.
Upvotes: 6