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.

BQ7695202: I2CCRC by default

Other Parts Discussed in Thread: BQ76952

Hi Experts,

Good day. I have a source code query about the implementation of I2C CRC frame protocol with BQ76952. I pasted the full query from client below.

>>
I work on project with BQ7695202 with the I2C CRC active by default.

I want to access and write in the dataram register.

I use the Battery management studio to capture I2CCRC frame and to understand precisely the protocole.

I try to write the value 12300 (0x300C) in the calibration register Vcell 1 (0x9180) to test.

In first, I send the following data:
Adress: 0x10
Start register: 0x3E
Data: 80 91 0C 30

In output, I have the I2C frame:
08 Equivalent to 0X10 adresse with shift logical for LSB to indicate Read or write 
3E Register
80 LSB register calibration
04 CRC with the 3 previously values.
91 MSB register calibration
FE CRC of the previously value
0C LSB data to write
24 CRC of the previously value
30 MSB data to write
90 CRC of the previously value.

This frame is OK.

To complete the write protocole, I send the folllowing data:
Adress: 0x10
Start register 0x60
Data: B2 06

In output, I have the I2C frame:
08: Equivalent to 0X10 adresse with shift logical for LSB to indicate Read or write.
60: Register
B2: Checksum = (adress bytes + data bytes) and complement.
40: ???
06: frame size (2 for address bytes + 2 for data byte + 1 for checksum size + 1 for frame size)
12: ???

My questions is on the second frame: the data 40 and 12.
It's look like crc value but, I don't undestood how they are computed.
And I don't found this information in the technical datasheet.The majority of the example are for I2C without CRC and for SPI protocol.

Could you indicate me how to compute these bytes? or the technical datasheet explain the process?
<<

For your guidance.

Thank you.

Regards,
Archie A.

  • Hi Archie,

    There are a couple examples of I2C with CRC in the BQ769x2 Software Development Guide, but it does not go into detail on the calculation. In your example, 0x40 and 0x12 are CRC bytes. 

    The first CRC byte is calculated after the first data byte. You write 0x08, 0x60, 0xB2 and then the CRC is computed because 0xB2 is the first byte of data being written. It is computed on (0x08, 0x60, 0xB2). If you put the string '1060B2' into the tool https://crccalc.com/ and select Hex as the Input type, you will see 0x40 calculated as the CRC-8 Result.

    Then 0x12 is the CRC for 0x06. 

    CRC calculation is not simple to explain, but there are many good web sites that explain the calculation in detail. Also, the code examples we have for this device include the CRC calculation function. Here are a couple sites to read about CRC:

    http://www.sunshine2k.de/articles/coding/crc/understanding_crc.html

    https://forum.digikey.com/t/crc-basics/13455

    Best regards,

    Matt