2025-05-14 2:19 AM - last edited on 2025-05-15 6:08 AM by Andrew Neil
Hello Community,
I’m currently working with an STM32G4 MCU and the BQ7697202 BMS IC, and I’m trying to establish basic I2C communication between the two. According to the BMS IC datasheet, I’ve configured the I2C address correctly, but I’m still unable to detect the IC on the bus.
Additionally, I implemented an I2C scan to search for available devices, but the scan returns “No device found.” Please find the attached I2C configurations for the reference.
Any guidance or suggestions would be greatly appreciated.
Thank you!
2025-05-14 3:21 AM - edited 2025-05-14 3:35 AM
Welcome to the forum.
Please see How to write your question to maximize your chances to find a solution for best results; in particular, please provide full hardware details and show your code.
Have you used an oscilloscope to verify your I2C waveforms? In particular, this will show if you have pullup problems.
Have you used an analyser (or the scope) to verify your I2C comms?
PS:
The BQ7697202 is a TI product - nothing to do with ST.
https://www.ti.com/product/BQ76972
Have you posted on their forums to verify your setup?
https://www.ti.com/product/BQ76972#support-training
You could post your analyser trace there for their comment ...
PPS:
@harshpanchal_6 wrote:I implemented an I2C scan to search for available devices, but the scan returns “No device found.”
Have you tested it with any other I2C devices?
2025-05-14 4:15 AM
Ensure pullups in the 1-5 kOhm range are present on SDA and SCL. Internal pullups are not sufficient.
Ensure pins are wired correctly.
Ensure target board is powered.
Show pictures of setup.
2025-05-14 4:18 AM
void I2C_ScanBus()
{
char msg[64];
uint8_t devicesFound = 0;
for (uint8_t address = 1; address < 127; address++)
{
if (HAL_I2C_IsDeviceReady(&hi2c3, address << 1, 1, 10) == HAL_OK)
{
snprintf(msg, sizeof(msg), "Found I2C device at 0x%02X\r\n", address << 1);
RS485_Transmit((uint8_t*)msg, strlen(msg));
devicesFound++;
}
}
if (devicesFound == 0)
{
RS485_Transmit((uint8_t*)"No I2C devices found\r\n", 23);
}
}
2025-05-15 3:16 AM - last edited on 2025-05-15 4:37 AM by Andrew Neil
Duplicate merged.
Please don't start multiple threads on the same topic.
Can you please review my code and suggest me any changes. Your help will be appreciated.
#define BQ76972_I2C_ADDR (0x10 << 1)
// 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);
}
// Writes 1 byte to BQ76972 register
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);
}
void BMS_ReadAndSend()
{
uint8_t regVal = 0;
if (BQ76972_ReadReg(BQ76972_I2C_ADDR, ®Val) == 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);
}
}
2025-05-15 4:39 AM
Please don't start multiple threads on the same topic.
You still haven't answered the questions I asked earlier:
Have you followed @TDK's suggestions? What were the results?
2025-05-15 4:41 AM
Yes, already tested
2025-05-15 5:28 AM
Focus on the hardware implementation
Focus on comprehensively answering questions posed and presenting in detail.
2025-05-15 6:06 AM - edited 2025-05-15 6:11 AM
@harshpanchal_6 wrote:Yes, already tested
So you have good, clean waveforms on both SDA and SCL, and you've got a trace of the comms with the BQ7697202?
So check that comms trace against the BQ7697202 datasheet - is it correct?
PS:
Have you looked at the support tools which TI proivde: https://www.ti.com/tool/BQSTUDIO ?