0
\$\begingroup\$

I'm using a LC709203FQH-01TWG Battery fuel gauge. I can read the data provided by the IC, like temperature, voltage, RSOC (Relative state of charge), etc. I can also modify the temperature value, but cannot change the battery profile, neither the APA (Adjustment Pack Application), however, I can change the temperature value without problems.

According to the datasheet, the i2c protocol for writing must be as follows:

I2C Write protocol for LC709203FQH

I'm calculating the CRC-8 code at https://crccalc.com/, using Hex type input. To select the battery profile, the datasheet indicates to use command code 0x12, and send word 0x00001 or 0x0000. So, to achieve this I'm sending the following data:

char lobData[4];    
lobData[0] = 0x01;
lobData[1] = 0x00;
lobData[2] = 0x72;
lobData[3] = '\0';
i2c_writeArray(0x16,0x12,lobData);      //Set Battery profile

Where i2c_writeArray is:

void i2c_writeArray(unsigned char acDeviceAddress, unsigned char acWriteToAddres, unsigned char* aobArray) {

int i = 0;

i2c_waitForIdle();
//START CONDITION
i2c_startCondition();

i2c_waitForIdle();
//SLAVE ADDRESS + W
i2c_writeByte(acDeviceAddress & 0b11111110);
//IDLE
i2c_waitForIdle();
//CHECK FOR SLAVE ACK
i2c_waitForAck();
//WORD ADDRESS
i2c_writeByte(acWriteToAddres & 0b11111110);
//IDLE
i2c_waitForIdle();
//CHECK FOR SLAVE ACK
i2c_waitForAck();
//IDLE
i2c_waitForIdle();
//WRITE DATA
while (aobArray[i] != '\0') {
    i2c_writeByte(aobArray[i]);
    i2c_waitForIdle();
    i2c_waitForAck();
    i ++;
}
//STOP CONDITION
i2c_stopCondition();
//IDLE
i2c_waitForIdle();

__delay_ms(10);
}

To calculate the CRC-8 I used:

CRC calculator online

The I2C protocol ends successfully, indicating the ACK's and data comunication is done, but I really don't know why trying to write the battery profile or apa is not working. Any help is appreciated.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.