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.

BQ27750: How to calculate CRC form MACData?

Part Number: BQ27750

Hello!

can anyone help me with CRC calculation for MACDataChecksum()?

For example I captured data from i2c bus when Studio work with chip:

i2c-1: Start
i2c-1: Write
i2c-1: Address write: 55
i2c-1: Data write: 3E
i2c-1: Data write: 3E
i2c-1: Data write: 46
i2c-1: Data write: E8
i2c-1: Data write: 03
i2c-1: Stop
i2c-1: Start
i2c-1: Write
i2c-1: Address write: 55
i2c-1: Data write: 60
i2c-1: Data write: 90
i2c-1: Data write: 06
i2c-1: Stop

as I can see:

Command 0x3E (AltManufacturerAccess)
Address: 0x463E
Data: E8 03
Command: 0x60 (MACDataChecksum)
CRC: 0x90
Length: 0x06

Right? Why Length is 6? may be two? or 4? But why 6? And How CRC is calculated?

Or other sequence:

0x55, 0x3E, 0x20, 0x46, 0x26, 0x02, 0x02, 0xF4, 0x01, 0x58, 0x02, 0x02, 0x26, 0x02, 0x00, 0x00, 0x02, 0x32, 0x00, 0x38, 0xFF, 0x02, 0x6A, 0xFF, 0xDC, 0x05, 0xB0, 0x04, 0x08, 0x07, 0x02, 0x00, 0xDC, 0x05

0x55, 0x60, 0x99, 0x22

i2c Dev: 0x55
Cmd: 0x3E
Address: 0x4620
Data: 0x26...0x05 (Length 30)
Cmd: 0x60
CRC: 0x99
Len: 0x22 (34)

0x22 is it length? Why 34? Cmd+Addres+Data+Len?
how calculated CRC?

  • As we mentioned in the bq27750 TRM, the checksum is the 8-bit sum of the MSB and LSB of the command plus the (command length) bytes in the buffer. The final sum is the bitwise inversion of the result. Since the length is part of the checksum, the verification cannot take place until the length is written. The checksum and length must be written together as a word to be valid.

  • Can you explain this by example based on data above?

  • See the details below.

    Command 0x3E (AltManufacturerAccess)
    Address: 0x463E
    Data: E8 03
    Command: 0x60 (MACDataChecksum)
    CRC: 0x90
    Length: 0x06

    The MacDataLength() is the total number of bytes written including the 2-byte MAC address, data bytes, 1-byte checksum, and 1-byte MACDataLength itself. Hence, the MACDataLength is 6.

    The MACDataChecksum() is the 8-bit sum of the MSB and LSB of the command plus the (command length) bytes in the buffer. The final sum is the bitwise inversion of the result.

    MACDataChecksum = 0xff - (0x46 + 0x3e + 0xe8 + 0x03) & 0xff =  0x90.

    If my post helped solve your issue, please click on the  This resolved my issue button. 

    Andy

  • Great! Thx a lot!