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: I2C communication between Stm32G4 and BQ76972 read/write failing

Part Number: BQ76972


Tool/software:

Hello everyone,

I’m currently implementing I²C communication between an STM32G4 microcontroller and the BQ76972 BMS IC. While a simple device scan correctly detects the IC’s address, every subsequent read/write operation fails. What might be causing this, and how can I resolve it?

Any advice would be greatly appreciated.

HAL_StatusTypeDef BQ76972_WriteReg(uint8_t regAddr, uint8_t data)
{
    return HAL_I2C_Mem_Write(&hi2c3, BQ76972_I2C_ADDR, regAddr, I2C_MEMADD_SIZE_8BIT, &data, 1, HAL_MAX_DELAY);
//    return HAL_I2C_Master_Transmit(&hi2c3, BQ76972_I2C_ADDR, TX_BUFF,sizeof(TX_BUFF), HAL_MAX_DELAY);
}


// Reads 1 byte from BQ76972 register
HAL_StatusTypeDef BQ76972_ReadReg(uint8_t regAddr, uint8_t* data)
{

    return HAL_I2C_Mem_Read(&hi2c3, BQ76972_I2C_ADDR, regAddr, I2C_MEMADD_SIZE_8BIT, data, 1, HAL_MAX_DELAY);
//	return HAL_I2C_Slave_Receive(&hi2c3, data, 1, HAL_MAX_DELAY);
}



void BMS_ReadAndSend()
{
    uint8_t regVal = 0;

    if (BQ76972_ReadReg(0x11, &regVal) == HAL_OK)
    {
        snprintf((char*)dataBuf, sizeof(dataBuf), "BQ76972 Reg 0x00 = 0x%02X\r\n", regVal);
        RS485_Transmit(dataBuf, strlen((char*)dataBuf));
    }
    else
    {
        RS485_Transmit((uint8_t *)"BQ76972 I2C Read Fail\r\n", 24);
    }
}

Thank you,
Harsh