Tool/software:
Hello Team,
I am working on establishing basic communication between the STM32 MCU and the BQ76972 IC. However, I’m encountering an issue where the write operation succeeds only once—subsequent attempts consistently fail.
Could you please help me investigate this problem?
The code is attached for your reference.
Thank you,
Harsh
// Simple I2C write between Stm32 and BQ76972 // HAL_StatusTypeDef BQ76972_WriteByte(uint8_t reg_addr, uint8_t data) { return HAL_I2C_Mem_Write(&hi2c3, BQ76972_I2C_ADDR_WRITE, reg_addr, I2C_MEMADD_SIZE_8BIT, &data, 1, HAL_MAX_DELAY); } void Test_Write_BQ76972(void) { char msg[64]; if (BQ76972_WriteByte(0x09, 0x00) == HAL_OK) { sprintf(msg, "Write to PROTECT1 OK\r\n"); RS485_Transmit((uint8_t*)msg, strlen(msg)); } else { sprintf(msg, "Write Failed\r\n"); RS485_Transmit((uint8_t*)msg, strlen(msg)); } }