Other Parts Discussed in Thread: BQ40Z50
Tool/software:
I am trying to write the serial number to the BQ40Z50 using command 0x1C via MCU I2C, but it's not working. I tried using Battery Management Studio, and it successfully writes the serial number to the BQ40Z50. It seems there is an issue with the checksum. I captured an I2C trace of Battery Management Studio writing the serial number. For example, if I write the serial number 0x0152 to the BQ40Z50, according to the I2C trace, the data sent is 0x1C, 0x52, 0x01, 0x6A, where 0x6A is assumed to be the checksum. If I send the same I2C trace via the MCU, it works, but when I use the checksum function from the application note SLUA801, it doesn't work.
However, the output of this function is different. Kindly guide me so I can write the desired serial number to the BQ40Z50.
//check_sum:
//pData: calculate check sum for block transfer pointer to data block
//nLength: length of data block
unsigned char check_sum(unsigned char *pData, unsigned char nLength)
{
unsigned char nSum = 0x00;
unsigned char n;
for (n = 0; n < nLength; n++)
nSum += pData[n];
nSum = 0xFF- nSum;
return nSum;
}