Tool/software:
I am interfacing BQ76952 with STM32 and i am able to read the Cell Voltage, current and temperature data and able to control the CHG and DSG Mosfets. I also want to use the Load detection on BQ76952 for that i have enabled the Load detection and set the Load detection active time, Retry delay and Timeout. Code for the same is given below. But the LD_ON is always 0 irrespective of load connection.
Can anyone confirm if it is the correct way to configure load detection and if not what is the correct way to configure the load detection. I want to use the load detection to wake up the AFE from sleep and to recover from short circuit and over discharge
CommandSubcommands(LOAD_DETECT_ON); // Enable theLoad Detect BQ769x2_SetRegister(0x92B4, 0x0050, 2); // Set Load Detect Active Time BQ769x2_SetRegister(0x92B5, 0x0010, 2); // Set Load Detect Retry Delay BQ769x2_SetRegister(0x92B6, 0x0078, 2); // Set Load Detect Timeout //Function to read LD_ON Status void BQ769x2_ReadControlStatus(void) { // Read Control Status for Load Detection DirectCommands(ControlStatus, 0x00, R); ControlBits = (RX_data[1]*256 + RX_data[0]); LD_ON = (0x1 & RX_data[0]);// Load Detection status } void CommandSubcommands(uint16_t command) //For Command only Subcommands // See the TRM or the BQ76952 header file for a full list of Command-only subcommands { //For DEEPSLEEP/SHUTDOWN subcommand you will need to call this function twice consecutively uint8_t TX_Reg[2] = {0x00, 0x00}; //TX_Reg in little endian format TX_Reg[0] = command & 0xff; TX_Reg[1] = (command >> 8) & 0xff; I2C_WriteReg(0x3E,TX_Reg,2); delay_1us(2000); } void BQ769x2_SetRegister(uint16_t reg_addr, uint32_t reg_data, uint8_t datalen) { uint8_t TX_Buffer[2] = {0x00, 0x00}; uint8_t TX_RegData[6] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; //TX_RegData in little endian format TX_RegData[0] = reg_addr & 0xff; TX_RegData[1] = (reg_addr >> 8) & 0xff; TX_RegData[2] = reg_data & 0xff; //1st byte of data switch(datalen) { case 1: //1 byte datalength I2C_WriteReg(0x3E, TX_RegData, 3); delay_1us(2000); TX_Buffer[0] = Checksum(TX_RegData, 3); TX_Buffer[1] = 0x05; //combined length of register address and data I2C_WriteReg(0x60, TX_Buffer, 2); // Write the checksum and length delay_1us(2000); break; case 2: //2 byte datalength TX_RegData[3] = (reg_data >> 8) & 0xff; I2C_WriteReg(0x3E, TX_RegData, 4); delay_1us(2000); TX_Buffer[0] = Checksum(TX_RegData, 4); TX_Buffer[1] = 0x06; //combined length of register address and data I2C_WriteReg(0x60, TX_Buffer, 2); // Write the checksum and length delay_1us(2000); break; case 4: //4 byte datalength, Only used for CCGain and Capacity Gain TX_RegData[3] = (reg_data >> 8) & 0xff; TX_RegData[4] = (reg_data >> 16) & 0xff; TX_RegData[5] = (reg_data >> 24) & 0xff; I2C_WriteReg(0x3E, TX_RegData, 6); delay_1us(2000); TX_Buffer[0] = Checksum(TX_RegData, 6); TX_Buffer[1] = 0x08; //combined length of register address and data I2C_WriteReg(0x60, TX_Buffer, 2); // Write the checksum and length delay_1us(2000); break; } }protection