Other Parts Discussed in Thread: BQ25895M
I am trying to use the BQ27421-G1 to monitor the battery's state of charge.The battery that we are using has a different design capacity, voltage and taper current, so we need to configure that after a system reset. Below is the list of I2C reads and writes that I perform to complete that process which I logged in my code.
I am having a couple problems occurring and I don't know if it related to the way that I am configuring the device, or the way we have implemented the IC in the design (we are also using a TI battery charger IC - BQ25895M), or a problem with the actual Fuel Gauge IC.
The first problem that I am having is that as I monitor the designCapacity using the 0x3C extended command, this command sometimes reports the default capacity of 1000 mAh instead of the 3000 mAh capacity that I have configured. Some times this reports such only once and then return to the configured capacity. Sometimes it gets stuck at the default. If I go back and read the capacity out of the data block region, it is still configured at 3000 mAh. It does this more frequently when I am connected to a charger.
The other problem that I am having is that the SoC seems to just switch between 0 and 100 - obviously if I reconfigure, it returns to 0 - but sometimes it just switches back and forth. It seems to do it primarily when I am connect to the charger.
All this to say that I have yet to get a good cycle of seeing the SoC dwindle from 100 down to discharged and then after connecting a charger to see it walk back up to 100%
Here is the I2C traffic when I am configuring the IC - I have annotated it so I can keep track of which command do what.
// Unseal
wr 0x00 0x00 0x80
wr 0x00 0x00 0x80
// Send CONFIG_UPDATE
wr 0x00 0x13 0x00
rd 0x06 0x37 0x01
// Enable Block Data memory control
wr 0x61 0x00 0x00
// Access State Subclass
wr 0x3E 0x52 0x00
wr 0x3F 0x00 0x00
// Get the current checksum
rd 0x60 0xE8 0x00
// Get the data for State Subclass
rd 0x40 0x00 0x00 0x00 0x00 0x00 0x81 0x0E 0xE6
0x0E 0xA4 0x03 0xE8 0x0E 0x74 0x15 0xCC
0x0C 0x80 0x00 0xC8 0x00 0x32 0x00 0x14
0x03 0xE8 0x01 0x00 0x64 0x10 0x68 0x00
wr 0x61 0x00 0x00
wr 0x3E 0x52 0x00
wr 0x3F 0x00 0x00
// Write back modified data
wr 0x40 0x00 0x00 0x00 0x00 0x00 0x81 0x0E 0xE6
0x0E 0xA4 0x0B 0xB8 0x2B 0x5C 0x15 0xCC
0x0B 0x54 0x00 0xC8 0x00 0x32 0x00 0x14
0x03 0xE8 0x01 0x00 0xEA 0x10 0x68 0x00
wr 0x60 0xF2 0x00
// Check that the checksum is correct
wr 0x3E 0x52 0x00
wr 0x3F 0x00 0x00
rd 0x60 0xF2 0x00
wr 0x61 0x00 0x00
// Access Registers subclass
wr 0x3E 0x40 0x00
wr 0x3F 0x00 0x00
rd 0x60 0xA2 0x00
rd 0x40 0x00 0x00 0x0F 0x10 0x00 0x14 0x04 0x00
0x09 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
wr 0x61 0x00 0x00
wr 0x3E 0x40 0x00
wr 0x3F 0x00 0x00
wr 0x40 0x05 0x00 0x0F 0x10 0x00 0x14 0x04 0x00
0x09 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
wr 0x60 0xBA 0x00
// Check that the checksum is correct
wr 0x3E 0x40 0x00
wr 0x3F 0x00 0x00
rd 0x60 0xBA 0x00
// Config Battery insert
wr 0x00 0x0C 0x00
// Perform SOFT RESET
wr 0x00 0x42 0x00
rd 0x06 0x17 0x01
// Seal the unit
wr 0x00 0x20 0x00