I read 7 bytes of info from an IC into an 8 byte array. The first byte returned is the number of bytes to be read to the mbed. That seems right if I output the results to terminal and do the maths.
I then copy all info from the "read" array into a "write" array (with the the offset address of the register I want to write to in position [0]). This to ensure that all info I am not manipulating is "as read" from the IC. I then manipulate the bits I want to change. I then write the register to the IC and read all the contents back a second time and display to terminal.
What I see after reading it a second time after writing is that the contents have shifted down by 1 from the first time I read.
Example:
First read
array[6] = 8
array[5] = 255
array[4] = 255
array[3] = 246
array[2] = 223
array[1] = 224
Second read
array[6] = 8
array[5] = 8
array[4] = 255
array[3] = 255
array[2] = 246
array[1] = 223
I am using a I2C address of 0x20 to address the IC. I am not changing it for read and write. I am not too familiar with I2C. Comments
I am also using the same register offset address for read and write. Is this correct?
Any suggestions?
I read 7 bytes of info from an IC into an 8 byte array. The first byte returned is the number of bytes to be read to the mbed. That seems right if I output the results to terminal and do the maths.
I then copy all info from the "read" array into a "write" array (with the the offset address of the register I want to write to in position [0]). This to ensure that all info I am not manipulating is "as read" from the IC. I then manipulate the bits I want to change. I then write the register to the IC and read all the contents back a second time and display to terminal.
What I see after reading it a second time after writing is that the contents have shifted down by 1 from the first time I read.
Example: First read array[6] = 8 array[5] = 255 array[4] = 255 array[3] = 246 array[2] = 223 array[1] = 224
Second read array[6] = 8 array[5] = 8 array[4] = 255 array[3] = 255 array[2] = 246 array[1] = 223
I am using a I2C address of 0x20 to address the IC. I am not changing it for read and write. I am not too familiar with I2C. Comments
I am also using the same register offset address for read and write. Is this correct?
Any suggestions?