This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

BQ27220: BQ27220 checksum calculation

Part Number: BQ27220

Bq27220 checksum calculation:

I am trying to set design capacity for BQ27220 from the default 3000mAH to 13200 mAH using the external MCU to write I2C command to update the RAM area of BQ27220. But when I follow the 16 steps described in TRM in Chapter 6 of bq27220 Technical Reference Manual (sluubd4.pdf) www.ti.com/.../sluubd4. However, the readback data is wrong if I follow the steps there.

Then I found the forum discussion here: Bq27220: Can not update data memory parameter e2e.ti.com/.../585243
and I follow the steps as described below:

"UPDATE : Got it working ! There is an error in the example, after the step 8, you need to repeat the steps 5 and 6 else there is an offset of 0x0200 in the parameter address. When you read dataLen the address pointer change and you are not anymore at the right position. The TI documentation for writing the data memory is very poor, it is difficult to understand how it is working because the paragraph "3.1 Accessing the Data Memory" is wrong, it is just a copy/paste from others battery fuel gauge..."

This time, i got it working to show the correct design capacity as 13200mAH. I hope TI can improve the bq27220 Technical Reference Manual so that to show the correct steps in the example.

Another issue I faced is the checksum calculation:
I am a bit confuse with the checksum calculation. So far, i found two ways of calculating the checksum:
Method 1) Checksum is (255 – x) where x is the 8-bit summation of the BlockData() (0x40 to 0x5F) on a byte-by-byte
basis.
Method 2) A quick way to calculate the new checksum uses a data
replacement method with the old and new data summation bytes.
Refer to the code for the indicated method.
Temp = mod(255 – Old_Chksum – OLD_DC_MSB – OLD_DC_LSB, 256);
New_Chksum = 255 – mod(temp + 0x04 + 0Xb0, 256);

I used both method to calculate the checksum, but i dont understand why i get the different checksum by using those two methods. I am in doubt whether they should end up with the same checksum. Can any expert confirm on this? Let me show you my calculation:

Method 1:

Here is the blockData (0x40 to 0x5F) : 0b b8 03 84 0e 74 00 64 0e 9f 00 95 03 63 0f be 01 3c 09 00 00 0b d7 01 0d 39 01 0d ad 01 10 4d

I get checksum = 0xD2 and the checksum read at register 0x60 is 0xA1. I don't understand how this checksum is calculated.

Method 2:

I use the method 2 to calculate the checksum, the result match 0xA1. [ temp= =MOD((255-161-11-184),256) = 155, new checksum=255 - [MOD((155+51+144),256)]= 255 -94 =161 (0xA1) which match what I read from the register 0x60.

My question is why the checksum calculation using the method 1 come out with wrong checksum? Did I actually read the wrong register again???

best regards,

kpk

  • You have to include the block address when calculating the check sum. That's why you don't get the correct check sum in Method 1.

    Here is a direct example for updating a parameter:
    An easy method to update a specific parameter is this sequence:

    1. Enter CFG_UPDATE mode
    2. Write the address AND the parameter data to 0x3E+ (auto increment)
    3. Calculate the check sum: 0xFF - (sum of address and data) OR 0xFF
    4. Write the check sum to 0x60 and the total length of (address + parameter data + check sum + length) to 0x61
    5. Exite CFG_UPDATE mode

    Example: Set OT Chg Time to 8 seconds:
    OT Chg Time address = 0x9234
    Data = 0x08

    2. write 0x34 0x92 0x08 to registers starting at 0x3E
    3. check sum = 0xFF - (0x34 + 0x92 + 0x08) OR 0xFF = 0xFF - 0xCE = 0x31
    4. write 0x31 to 0x60 and 0x05 (=2 bytes address, 1 byte data, 1 byte check sum, 1 byte length) to 0x61
  • HI Dominik,

    Thx, this clear my doubt.

    very helpful

    Best regards,
    kpk

  • hi Dominik,

    Can I confirm with you on the following:
    1. Now, I am able to write to the design capacity register correctly. However, after going through many cycles of full charge to full discharge but the FCC [FullChargeCapacity()] still reads the default value of 3000mAh.

    It looks like BQ27220 is not able to detect when the battery is Fully charged or empty. Did I missing any steps?
    Note: the end cust do not want to use OTP method.

    best regards,
    kpk