Quantcast
Channel: Power management forum - Recent Threads
Viewing all articles
Browse latest Browse all 35901

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

$
0
0

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.


Viewing all articles
Browse latest Browse all 35901

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>