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.

[参考译文] BQ76972:MCU 和 BQ76972 之间的间歇性 I2C 通信 CRC 错误。

Guru**** 2604225 points
Other Parts Discussed in Thread: BQ76972

请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/power-management-group/power-management/f/power-management-forum/1581418/bq76972-intermittent-i2c-communication-crc-error-between-mcu-and-bq76972

器件型号:BQ76972


您好的团队、
我使用 GD32 MCU 与 BQ76972 通信、其中 CRC 在 100kHz 下启用。
CRC 失败大约每几分钟发生一次。
所有故障都发生在直接命令读取的第一个 CRC 字节上。
该 CRC 是从{0x10、直接命令地址、0x11、第一个数据字节}计算得出的。
如果命令字节为 0x70、则 BQ76972 返回的坏 CRC 始终是您获得的值。
示例:使用 0x14 读取电芯 1 电压、器件返回{0xE4、0xF0、0x0C、0x24}。
数据 0x0CE4 = 3300⇔3.3V、正确。
{0x10、0x14、0x11、0xE4}的 CRC 为 0x9E、但芯片发送 0xF0、这是{0x10、0x70、0x11、0xE4}的 CRC。
我的 CRC 例程:
static uint8_t calculate_crc8(uint8_t *ptr, uint8_t len)
{
    uint8_t i;
    uint8_t crc = 0;
    while (len--) {
        for (i = 0x80; i != 0; i /= 2) {
            if ((crc & 0x80) != 0) {
                crc *= 2;
                crc ^= 0x07;
            } else {
                crc *= 2;
            }
            if ((*ptr & i) != 0) {
                crc ^= 0x07;
            }
        }
        ptr++;
    }
    return crc;
}

请帮助查找问题。

 

谢谢您、

标记