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.

BQ76920: CRC generation and I2C slave addess

Part Number: BQ76920
Other Parts Discussed in Thread: BQ76952

Hi 

I have found your sample code: bq769x0_I2C_sample_code_with CRC in the file sluc583.zip

My question is: Why is the I2C slave address multiplied with 2 before the CRC byte is calculated? e.g:

int I2CWriteRegisterByteWithCRC(unsigned char I2CSlaveAddress, unsigned char Register, unsigned char Data)
{
unsigned char DataBuffer[4];
unsigned int SentByte = 0;

DataBuffer[0] = I2CSlaveAddress << 1;   ???????
DataBuffer[1] = Register;
DataBuffer[2] = Data;
DataBuffer[3] = CRC8(DataBuffer, 3, CRC_KEY);

return(I2CSendBytes(I2CSlaveAddress, DataBuffer + 1, 3, &SentByte));
}

I2CSendBytes uses the I2CSlaveAddress, but the calculated CRC byte is not calculated with this address (0x08, but 0x10) the command should then be rejected !

Best Regards

Lars Jensen
LINAK A/S

  • Hi Lars,

    I am not the author for this sample program, but I suspect it is the way the MCU writes the 8 bits. The BQ76920 datasheet shows the I2C address is 7 bits plus a R/W bit. The MCU is using an 8-bit address (R/W bit included) so it needs to shift the bits by one place.

    In another example for a different device, the BQ76952 datasheet shows an 8-bit I2C address that included the R/W bit and defines this address as 0x10 (this is really the same address as the BQ76920).

    So for both of these devices, the CRC is actually calculated over an 8-bit address.

    Best regards,

    Matt

  • Many thanks for your fast reply.

    Best regards

    Lars Jensen
    LINAK A/S