您好!
我使用了 BQ4050和 nRF52832。 我从 BQ4050获得了以下损坏的数据。
最后一个标记的值、即 DAStatus2Reg (0x72)的温度。 它运行良好、但随机运行、故障。
如何解决此问题? 请帮帮我。
APP:BMS (3:37:57):11178 12400 2679
APP:BMS (3:37:58): 11178 12400 2679
APP:BMS (3:37:59):11179 12400 2679
APP:BMS (3:38:0):11178 12400 2679
应用程序:BMS (3:38:1):11178 12400 2679
应用程序:BMS (3:38:2):11178 12400 2679
应用程序:BMS (3:38:3):11178 12400 2679
应用程序:BMS (3:38:4):11178 12400 2679
应用程序:BMS (3:38:5):11178 12400 2679
应用程序:BMS (3:38:6):11178 12400 2679
应用程序:BMS (3:38:7):11178 12400 2679
应用程序:BMS (3:38:8):11178 12400 -275
应用程序:BMS (3:38:9):11178 12400 -275
我的读取代码如下所示、
void read_BQ4050_data (uint8_t regAddress、uint8_t size)
{
RET_CODE_t ERR_code;
uint8_t reg[1]={regAddress};
uint8_t buf[2]={0};
ERR_code = nrf_drv_twi_TX (&m_twi、BQ4050_wher_am_i、reg、sizeof (reg)、false);
APP_ERROR_CHECK (ERR_code);
tWI_done ();
开关(尺寸)
{
案例1:
ERR_code = nrf_drv_twi_Rx (&m_twi、BQ4050_wher_am_i、m_buf8、size);
中断;
案例2:
ERR_code = nrf_drv_twi_Rx (&m_twi、BQ4050_wher_am_i、(uint8_t *) m_buf16、size);
中断;
案例4:
ERR_code = nrf_drv_twi_Rx (&m_twi、BQ4050_wher_am_i、m_buf、size);
中断;
默认值:
ERR_code = nrf_drv_twi_Rx (&m_twi、BQ4050_wher_am_i、m_buf、size);
中断;
}
APP_ERROR_CHECK (ERR_code);
tWI_done ();
switch (regAddress)
{
Case StateOfChargeReg:
m_bms_measurement1->realSOC =(uint8_t) m_buf8[0];
中断;
Case CellVoltageOne:
m_bms_measurement1->cellV[0]= m_buf16[0];
//ERR_CHECK_READ (&m_BMS_measurement1->CELLV[0]、&PRE_CV1、1);
中断;
Case CellVoltageTwo:
m_bms_measurement1->cellV[1]= m_buf16[0];
//ERR_CHECK_READ (&m_BMS_measurement1->CELLV[1]、&PRE_CV2、1);
中断;
Case CellVoltageThree:
m_bms_measurement1->cellV[2]= m_buf16[0];
//ERR_CHECK_READ (&m_BMS_measurement1->CELLV[2]、&PRE_CV3、1);
中断;
Case CellVoltageFour:
m_bms_measurement1->cellV[3]= m_buf16[0];
//ERR_CHECK_READ (&m_BMS_measurement1->CELLV[3]、&PRE_cV4、1);
nrf_log_info ("单元格 V:%d %d %d %d %d %d %d %d "、m_bms_measurement1->cellV[0]、m_bms_measurement1->cellV[1]、m_BMS_measurement1->cellV[2]、m_BMS_cellurement1->V[3];
中断;
案例电流寄存器:
m_bms_measurement1->packCurrent = m_buf16[0];
//m_BMS_measurement1->packCurrent = 21000;
//ERR_CHECK_READ (&m_BMS_measurement1->CELLV[2]、&PRE_CV3、1);
//nrf_log_info ("Pack C:%d"、m_BMS_measurement1->packCurrent);
中断;
案例卷注册:
m_bms_measurement1->packVoltage = m_buf16[0];
ERR_CHECK_READ (&m_BMS_measurement1->packVoltage、&pre_PV、1);
//nrf_log_info ("Pack V:%d"、m_BMS_measurement1->packVoltage);
中断;
实例操作状态注册器:
m_status_bq4050->OperationStatus = byte2short (m_buf[1]、m_buf[2]);
中断;
案例制造商状态注册器:
m_status_bq4050->ManufacturingStatus = byte2short (m_buf[1]、m_buf[2]);
中断;
案例状态2注册:
m_bms_measurement2->temperature [0]= byte2short (m_buf[3]、m_buf[4])-KTEMP_PARAM;
m_bms_measurement2->temperature [1]= byte2short (m_buf[5]、m_buf[6])-KTEMP_PARAM;
m_bms_measurement2->temperature [2]= byte2short (m_buf[7]、m_buf[8])-KTEMP_PARAM;
m_bms_measurement2->temperature [3]= byte2short (m_buf[9]、m_buf[10])-KTEMP_PARAM;
//nrf_log_info ("Pack Temp:%d"、m_bms_measurement2->temperature [0]);
中断;
}
}