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: TS3 Subclass and offset is getting fail

Part Number: BQ76972

Tool/software:

Hello TI team,

I am writing TS3 configurations with accurate data as per the datasheet and technical reference manual but it is getting fail. I have attached the code and the output logs and the waveforms. As per my understanding I am not receiving the ACK on I2C channel. Please, let me know if any suggestions on this.

void 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));


}

  • Hi Harsh, 

    Please refer to the Technical Reference Manual (https://www.ti.com/lit/ug/sluuby2b/sluuby2b.pdf) for instructions about the register and how to communicate with the device. We can answer specific question about the device, however we expect our customer to be able to review/debug their code. If you have an issue with the microcontroller, please reach out to the MCU team. If you have a specific question about the TRM, please post another thread with the same.

    If you are getting a NACK, something is not working on your systems or I2C IRQ. I will start making sure your program is sending the right commands. You can use our GUI to debug alongside a protocol analyzer, to compare your code with ours and adjust as needed. 

    Thank you. 

    Regards, 

    Arelis G. Guerrero