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.

Use TI-27621-G1 gauge to update RAM parameter but get FAILURE and why?

When our device insert battery (4200mAh) for the system, I would like to update RAM parameter

by changing default 2425mAh to 4200mAh to get correct charge info from gauge.

but when I follow spec’s update procedure as attached file.
I still can not get new design capacity 0x1068 (4200) but 0x979 (2425)
and the checksum read from NV is wrong (not 0x8A) and also my updating checksum (0x94) for new
battery is also failed to write.

- Program I2C write without errors.
- But try to update design capacity and update its checksum, when i read them out, it's all default value.
- Paste my commands,

UINT8 cmd_UnSeal[] = {0x00, 0x00, 0x80};
UINT8 cmd_Seal[] = {0x00, 0x20, 0x00};
UINT8 cmd_CfgUpdate[] = {0x00, 0x13, 0x00};
UINT8 cmd_FlagRead[] = {0x06/*, 0x0*/};
UINT8 cmd_BlockControl[] = {0x61, 0x00};
UINT8 cmd_DataClass[] = {0x3E, 0x52};
UINT8 cmd_DataBlock[] = {0x3F, 0x00};
UINT8 cmd_BlockCs[] = {0x60};
UINT8 cmd_Read_Dc1[] = {0x43, 0x00};
UINT8 cmd_Read_Dc2[] = {0x44};
UINT8 cmd_Write_Dc1[] = {0x43, 0x9};
UINT8 cmd_Write_Dc2[] = {0x44, 0x79};
UINT8 cmd_SoftReset[] = {0x00, 0x42, 0x00};
UINT8 cmd_Read[] = {0x0};
UINT8 cmd_ExitCfgUpdate[] = {0x00, 0x44, 0x00};

== function code here start

void Test_Data_Memory_Access()
{
UINT8 answer[4] = {0, 0, 0, 0}, command[3] = {0}, val = 0, result, flg_register, old_cs, new_cs, old_MSB, old_LSB;
int tmp;
static UINT8 init_flg = 0, cnt_flg = 0;

ble_trace0("\n--- Test_Data_Memory_Access. \n\r");

// unseal and config mode.
val = i2cm_write_to_slave(cmd_UnSeal, 3, I2C_SLAVE_GAUGE);

val = i2cm_write_to_slave(cmd_UnSeal, 3, I2C_SLAVE_GAUGE);

val = i2cm_write_to_slave(cmd_CfgUpdate, 3, I2C_SLAVE_GAUGE);

val = i2cm_write_then_read_from_slave(cmd_FlagRead, 1, answer, 2, I2C_SLAVE_GAUGE);


do {
if((answer[0] & 0x10) == 0x10)
break;
bleapputils_delayUs(I2C_DELAY); //Wait I2C_DELAY μs (start-up delay)

val = i2cm_write_then_read_from_slave(cmd_FlagRead, 1, answer, 2, I2C_SLAVE_GAUGE);
} while((answer[0] & 0x10) == 0x00);

ble_trace2("\n--- cmd_FlagRead: %x %x.\n\r", (UINT8)answer[0], (UINT8)answer[1]);


// start to enter block operation.
val = i2cm_write_to_slave(cmd_BlockControl, 2, I2C_SLAVE_GAUGE);
result |= val;

val = i2cm_write_to_slave(cmd_DataClass, 2, I2C_SLAVE_GAUGE);
result |= val;

val = i2cm_write_to_slave(cmd_DataBlock, 2, I2C_SLAVE_GAUGE);

val = i2cm_write_then_read_from_slave(cmd_BlockCs, 1, answer, 1, I2C_SLAVE_GAUGE);
result |= val;
if (result == 1) {
ble_trace2("\n--- Block old cs: %x %x.\n\r", (UINT8)answer[0], (UINT8)answer[1]);
}

old_cs = answer[0];

val = i2cm_write_then_read_from_slave(cmd_Read_Dc1, 1, answer, 1, I2C_SLAVE_GAUGE);
result |= val;
if (result == 1) {
ble_trace2("\n--- cmd_Read_Dc1: %x %x.\n\r", (UINT8)answer[0], (UINT8)answer[1]);
}
else
ble_trace1("\n--- Update config query Fail: %d \n\r", result);

old_MSB = answer[0];

val = i2cm_write_then_read_from_slave(cmd_Read_Dc2, 1, answer, 1, I2C_SLAVE_GAUGE);
result |= val;
if (result == 1) {
ble_trace2("\n--- cmd_Read_Dc2: %x %x.\n\r", (UINT8)answer[0], (UINT8)answer[1]);
}
else
ble_trace1("\n--- Update config query Fail: %d \n\r", result);

old_LSB = answer[0];

ble_trace1("\n--- Old Desgin Capacity is : %d \n\r", old_LSB | old_MSB<<8);

val = i2cm_write_to_slave(cmd_Write_Dc1, 2, I2C_SLAVE_GAUGE);
result |= val;

val = i2cm_write_to_slave(cmd_Write_Dc2, 2, I2C_SLAVE_GAUGE);
result |= val;

tmp = mod((int)(255-old_cs-old_MSB-old_LSB), (int)256);

new_cs = 255-mod((int)(tmp + 0x10 + 0x68), (int)256);

command[0] = 0x60;
command[1] = new_cs;

ble_trace1("\n--- New Cs: %x \n\r", new_cs);

result |= val;

// exit cfg_update and seal it.
bleapputils_delayUs(I2C_DELAY); //Wait I2C_DELAY μs (start-up delay)

val = i2cm_write_to_slave(cmd_SoftReset, 3, I2C_SLAVE_GAUGE);
result |= val;

val = i2cm_write_then_read_from_slave(cmd_FlagRead, 1, answer, 2, I2C_SLAVE_GAUGE);

do {
if((answer[0] & 0x10) == 0x00)
break;
bleapputils_delayUs(I2C_DELAY); //Wait I2C_DELAY μs (start-up delay)
val = i2cm_write_then_read_from_slave(cmd_FlagRead, 1, answer, 2, I2C_SLAVE_GAUGE);

} while(answer[0] & 0x10 == 0x10);

ble_trace2("\n--- cmd_FlagRead: %x %x.\n\r", (UINT8)answer[0], (UINT8)answer[1]);

val = i2cm_write_to_slave(cmd_Seal, 3, I2C_SLAVE_GAUGE);
bleapputils_delayUs(I2C_DELAY); //Wait I2C_DELAY μs (start-up delay)
result |= val;val = i2cm_write_to_slave(command, 2, I2C_SLAVE_GAUGE);

}

== function code here end.

  • Hello Leo,

    What is the delay between your transactions?

    Can you try sending the following commands with the appropriate delays attached in this presentation.

    Also, if you have scope captures of your I2C transactions or if you can sniff the I2C bus to get the exact commands received by the gas gauge, then that will help us debug what is going wrong. It looks like your checksum of 0x94 is correct, however, let's make sure your sequence is correct as well.

    5444.Commands.zip

    Thanks,

    Kang Kang

  • Dear Kang Kang,

    Thanks for ur updated info and it should be helpful.
    If still any problem exists, feel free to contact with me?
    maybe its faster to contact with u directly, leo_su@coasia.com.tw

  • Dear Kang,

    I use 2 ways to update capacity but all failed; can u help me check any problem found,

    - Follow TI-27621-G1 spec.,Gauge_updatedCapacity_failure2.csv:
    Its often failed at  the command set of  SET_CFGUPDATE, the 4th bit of FLAG()
    not easy to be set or to be clear and even if its ok sometimes, it is still can not be updated.


    - ur suggested file and commands
    there is one command line shows,
    33Byte, 

    40 43 33 00 10 68 1C 6B 09 79 0C 80 00 C8 00 32 00 14 03 E8 01 00 C8 10 04 00 0A 10 5E FF CE FF CE

    but from I2C captured in our system the 33-byte length will be truncated as the snapshot, Gauge_updatedCapacity_failure1.jpg.

    Besides, the 2nd way's command process is different from the one from spec. when updating
    design capacity (cmd = 0x43 and 0x44) before updating checksum. Do u know which one is correct?