Part Number:BQ34Z100-G1
Hello,
I am using the Bq34z100-G1 battery gauge on a custom design including a TI MSP43053359.
I am trying to configure for the first time the gauge using MSP430 I2C, but without success.
Here are the steps I follow to configure two values: the design capacity, and the design energy. These entries are found in the sublass with id 48.
When reading the gauge, I expect to get all default values, since I have never configured it before.
This is not exactly my results, though, as you will see.
First, I enable block data, writing 0x61 and 0x00 to the I2C address.
Then, I give the subclass that I target as the block data: wr 0x3E 0x30 (48 <=> 0x30)
Then, I give the offset for my entries (here this is 0): wr 0x3F 0x00
Then, I read 32 bytes from the block data address (0x40)
Here are the 32 bytes I get:
0x10 0x00 0x00 0x00 0x01 0x00 0x00 0x03 0x84 0x64 0x03 0xE8 0x15 0x18 0xFE 0x70 0x10 0x68 0x10 0x68 0x10 0x04 0x0A 0x32 0x1E 0x00 0x0A 0x2D 0x37 0x01 0x0B 0x97
Here are the expected 32 bytes, according to the documentation of the battery gauge
0xXX 0xXX 0x00 0x00 0x00 0x01 0x00 0x00 0x03 0x84 0x64 0x03 0xE8 0x15 0x18 0xFE 0x70 0x10 0x68 0x10 0x68 0x10 0x04 0x0A 0x32 0x1E 0xF6 0x0A 0x2D 0x37 0x01 0x62
I notice a shift between expected results and what I get.
Anyway, thanks to the easily identifiable default values for design capacity and design energy, I could find their place in the byte stream.
So, i update the corresponding values in the byte stream and write them:
Design capacity: bytes_stream[10] = 0xa0; byte_stream[11] = 0x28;
wr (0x40 + 10) 0xa0 0x28
Design energy: bytes_stream[12] = 0x4b; byte_stream[13] = 0x28;
wr (0x40 + 12) 0x4b 0x28
Then I compute the checksum:
0x10 + 0x00 + 0x00 + 0x00 + 0x0I1 + 0x00 + 0x00 + 0x03 + 0x84 + 0x64 + 0x03 + 0xE8 + 0x15 + 0x18 + 0xFE + 0x70 + 0x10 + 0x68 + 0x10 + 0x68 + 0x10 + 0x04 + 0x0A + 0x32 + 0x1E + 0x00 + 0x0A + 0x2D + 0x37 + 0x01 + 0x0B + 0x97 = 0x74
checksum = 0xFF - 0x74 = 0x8b
Then write it:
wr 0x60 0x8b
Then I reset the gauge :
wr 0x00 0x41 0x00
Then wait 300 millis.
But when I read the entries back I get the default values again:
0x10 0x00 0x00 0x00 0x01 0x00 0x00 0x03 0x84 0x64 0x03 0xE8 0x15 0x18 0xFE 0x70 0x10 0x68 0x10 0x68 0x10 0x04 0x0A 0x32 0x1E 0x00 0x0A 0x2D 0x37 0x01 0x0B 0x97
What am I doing wrong ?