So for example, lets say I want to write the register at 0x05, and set bits 0-3 as the value 1 (forget the other bits, they're not important yet), I'm doing whats shown below. But its not working. When I read it back, its not how I set it. What am I doing wrong?
Is it working yet? I'm guessing not.
Now that I read the datasheet you linked to, I have to say it is one of the more confusing documents I have read.
After staring at it for a while I think
they are saying that the device address is in fact the register. So, for example, say we want to set some bits in register 2:
15: DHIZ (1)
14: DMUTE (1)
13: MONO (0)
12: BASS (1)
11: RESERVED (0)
10: CLK32 (0)
8-7: RESERVED (0)
6-4: CLK_MODE (0)
1: SOFT RESET (0)
0: ENABLE (1)
So lets turn them into bits with the example values above:
| | |
15 8 0
So we may as well split them up ourselves:
byte highCommand = 0b11010000;
byte lowCommand = 0b00000010;
If I'm right, we now need to send to register (address) 2 on the device:
And to get them back:
if (Wire.requestFrom (2, 2) != 2) // read from register 2, for 2 bytes
byte readHigh = Wire.read ();
byte readLow = Wire.read ();
Try that and see. Also try my I2C scanner on this page:http://www.gammon.com.au/i2c
If my theory is correct you will see it reporting that addresses 2, 3, 4, 5, 0x0A, 0x0B are on the bus.