I have some doubt about how to use wire.h when I need to work with some I2C device with 7 bit device address, 16/24 bit register address and 24/32 bit register size.
For example the ADE7953 have many registers sized 24/32bit and 16 bit address :
Register: AWATT
Address (24 bit Data) 0x212
Address (32 bit Data) 0x312
As you can see, the register address is 16 bit long and register size is 24 or 32 bit long.
It is possible to use wire.h in this case?
It seems that wire.h could work only with 8 bit long address registers...
Thank you in advance for your kindly help,
best regards,
Mik
no, I already read (and read again, and again, and again... ) the datasheet of the device.
As you can see:
I2C device address : is 7 bit long (+1 bit for R/W)
Register Address: is 16 bit long
Data : is 24/32 bit long
But the answer is still the same: how can I use wire.h with 16 bit register address size?
Michelelos, you might be confused with those low level I2C descriptions. But most of the things at page 53 and 54 are automatically done by the Wire library.
I prefer to name the "register address" as "register", but I will call it register_address.
And prefer to name "register" as "data".
As you can see, they are just a bunch of Wire.write().
To read from the chip:
Wire.beginTransmission( slave_address);
Wire.write( highByte( register_address));
Wire.write( lowByte( register_address));
Wire.endTransmission();
Wire.requestFrom( slave_address, 4);
// use Wire.read() 4 times, and store it in a 32-bit integer.
// probably with shifting
...