请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。
器件型号:BQ76952 工具与软件:
我将 BQ76952与 STM32连接、我能够读取电池电压、电流和温度数据、并能够控制 CHG 和 DSG MOSFET。 我还需要在 BQ76952上使用负载检测、因为我已启用 负载检测 并设置 负载检测运行时间 、 重试延迟 和 超时 . 下面给出了相同的代码。 但是 LD_ON I S 始终为0 与负载连接无关。
任何人都可以确认配置负载检测的正确方法是否正确、以及配置负载检测的正确方法是否正确。 我想使用负载检测功能将 AFE 从睡眠状态中唤醒、并从短路和过放电中恢复
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; } }保护