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