Tool/software:
Hello TI team,
I was trying to write configurations as per the technical reference manual of BQ76972 but unfortunately I am receiving error as I have also checked the waveforms. As BMS IC is not acknowledging I2C writes to 0x3E, which is how I can begin memory writes. In addition, I have entered exact same addresses and commands according to the reference manual. I write subclass "0x80" and offset "0x5C" which comes from "0x92FF-0x92A3 = 0x5C". Here 0x92A3 because it is the starting base address of subclass "0x80". So, please help me out here for any correction.
I have attached the code and requirevoid BQ76972_Unseal(I2C_HandleTypeDef *hi2c3)
{
char message[64];
uint8_t unseal_key1[] = { 0x14, 0x04 };
uint8_t unseal_key2[] = { 0x72, 0x36 };
if(HAL_I2C_Mem_Write(hi2c3, BQ76972_I2C_ADDR_WRITE, 0x00, I2C_MEMADD_SIZE_8BIT, unseal_key1, 2, 100) == HAL_OK)
{
snprintf(message, sizeof(message),"Unseal success\r\n");
RS485_Transmit((uint8_t*)message, strlen(message));
}
else
{
snprintf(message, sizeof(message), "Unseal Step 1 failed\r\n");
RS485_Transmit((uint8_t*)message, strlen(message));
}
HAL_Delay(5);
HAL_I2C_Mem_Write(hi2c3, BQ76972_I2C_ADDR_WRITE, 0x74, I2C_MEMADD_SIZE_8BIT, unseal_key2, 4, 100);
HAL_Delay(5);
}
void BQ76972_Enter_ConfigUpdate(I2C_HandleTypeDef *hi2c3)
{
char config_msg_1[30];
uint8_t cfgupdate_cmd[] = { 0x90, 0x00 }; // Subcommand = 0x0090
if(HAL_I2C_Mem_Write(hi2c3, BQ76972_I2C_ADDR_WRITE, CMD_SUBCOMMAND, I2C_MEMADD_SIZE_8BIT, cfgupdate_cmd, 2, 100) == HAL_OK)
{
snprintf(config_msg_1, sizeof(config_msg_1),"Config. mode success\r\n");
RS485_Transmit((uint8_t*)config_msg_1, strlen(config_msg_1));
}
HAL_Delay(5);
}
void BQ76972_WriteTS3Config(I2C_HandleTypeDef *hi2c3)
{
char wr_ts3_msg[64];
// Step 1: Set offset and subclass
uint8_t offset_subclass[2] = { 0x5C, 0x80 };
if(HAL_I2C_Mem_Write(hi2c3, BQ76972_I2C_ADDR_WRITE, 0x3E, I2C_MEMADD_SIZE_8BIT, offset_subclass, 2, 100) == HAL_OK)
{
snprintf(wr_ts3_msg, sizeof(wr_ts3_msg),"Offset and Subclass pass\r\n");
RS485_Transmit((uint8_t*)wr_ts3_msg, strlen(wr_ts3_msg));
}
else
{
snprintf(wr_ts3_msg, sizeof(wr_ts3_msg),"Offset and Subclass fail\r\n");
RS485_Transmit((uint8_t*)wr_ts3_msg, strlen(wr_ts3_msg));
return;
}
HAL_Delay(2); // allow time for memory map
// Step 2: Write TS3 config value into data buffer (0x40)
uint8_t ts3_cfg_value = 0x03;
if(HAL_I2C_Mem_Write(hi2c3, BQ76972_I2C_ADDR_WRITE, 0x40, I2C_MEMADD_SIZE_8BIT, &ts3_cfg_value, 1, 100) != HAL_OK)
{
snprintf(wr_ts3_msg, sizeof(wr_ts3_msg),"TS3 Data Write fail\r\n");
RS485_Transmit((uint8_t*)wr_ts3_msg, strlen(wr_ts3_msg));
return;
}
HAL_Delay(2);
// Step 3: Write length = 0x01 to 0x61 (tells BQ to commit 1 byte)
uint8_t len = 0x01;
if(HAL_I2C_Mem_Write(hi2c3, BQ76972_I2C_ADDR_WRITE, 0x61, I2C_MEMADD_SIZE_8BIT, &len, 1, 100) != HAL_OK)
{
snprintf(wr_ts3_msg, sizeof(wr_ts3_msg),"Length commit fail\r\n");
RS485_Transmit((uint8_t*)wr_ts3_msg, strlen(wr_ts3_msg));
return;
}
HAL_Delay(5);
snprintf(wr_ts3_msg, sizeof(wr_ts3_msg),"TS3 Config. Write Success\r\n");
RS485_Transmit((uint8_t*)wr_ts3_msg, strlen(wr_ts3_msg));
}
d output data's for the reference.