Hi
I am working to try and communicate with a BQ4050 battery fuel gauge from TI. There are some settings that are stored on board in flash memory. On page 92 of the technical reference manual there is some info on how to read and write to these registers.
As I understand the format is:
Device address, write bit
0x44
reg address LSB
reg address MSB
then
Device address, read bit
0x44
read byte
The thing that I don't understand is when using the wire library I have the following code
byte readDFByteReg( char devAddress, byte regAddress1, byte regAddress2 ){
byte dataByte = 0;
byte sentData[3] = { 0x44, regAddress2, regAddress1 };
Wire.beginTransmission( devAddress );
Wire.send( sentData, 3 );
Wire.endTransmission();
delay(5);
Wire.requestFrom( devAddress , 1);
Wire.write( 0x44 );
if( Wire.available() > 0 ){
dataByte = Wire.receive();
}
return dataByte;
}
But when I look at the output of the pins, the Arduino always ends the transmission after sending only 2 of the 3 bytes. I have tried sending 4 or 5 bytes, but it still will only send 2 bytes. As I understand the transmit buffer size is 32 bytes, so I'm a littel confused as to why I can only send 2 bytes. Is it because the device is nacking after the 2nd byte?
Thanks