11 years, 1 month ago.

Add access bit or not?

Hi, all,

it is known that the IIC communication needs an access bit at the end of address. In my case, the slave device's IIC address is 0x0D. So do I use XXX.write(0x0D,a, 2) and XXX.read(0x0D,a, 2) or XXX.write(0x1A,a, 2) and XXX.read(0x1B,a, 2) ?

That is to say, do I need to manually add the access bit 0/1 to the address when using the read and write function? Thank you so much for the help!

Question relating to:

1 Answer

11 years, 1 month ago.

You need to use the 8-bit address in the I2C function, and the last bit is irrelevant. So looking at your example you want to use 0x1A. 0x1B also works, but imo it is clearer to just stick to LSB being 0, but it doesnt actually matter. And thats for both read and write.

Thank you Erik! I was asking because the data sheet from my slave device said the I2C address is 0x0D = b0001101, the address byte is as follows, address (0x0D) + access bit (R/W)

0001101 0 (write) = 0x1A 0001101 1 (read) = 0x1B

And when I reading the sample program on mbed here, people just use the same address for both read and write. So that confuses me.

posted by Cheng Cheng 31 Mar 2013