Part Number: BQ25731EVM
Other Parts Discussed in Thread: BQ25731
Tool/software:
I am stuck at trying to read VBAT and VSYS using the i2c commands. I am using the BQ25731EVM.
I have 2 function calls. I can read the adc of the VBUS no problem and see 5.3V. but for whatever reason i get 768mV as the return value for VBAT and VSYS. i see no difference between the PSYS and VBUS register and the way to read, but VBAT and VSYS are not giving proper value of 3.6V, and instead are showing 768mV
bq25731_dev.set_low_power_mode(0);
result = bq25731_dev.set_adc_enable(EN_ADC_VBAT | EN_ADC_VBUS | EN_ADC_VSYS);
bq25731_dev.set_adc_operation(ADC_START | ADC_FULLSCALE);
delay(75); //25ms required per EN entry from set_adc_enable
Serial.print("ADC_Option: 0x");
Serial.println(result, HEX);
Serial.print("Input Voltage Voltage: ");
Serial.print(bq25731_dev.get_adc_vbus() * 96);
Serial.println("mV");
Serial.print("SYS Voltage Voltage: ");
Serial.print(bq25731_dev.get_adc_vsys() * 64);
Serial.println("mV");
Serial.print("Battery Voltage: ");
Serial.print(bq25731_dev.get_adc_vbat() * 64);
Serial.println("mV");
struct {
uint8_t psys;
uint8_t vbus;
} REG_ADC_VIN;
struct {
uint8_t vsys;
uint8_t vbat;
} REG_ADC_VOUT;
Same basic calls:
uint8_t bq25731::get_adc_vbus(void){
get_adc_vbuspsys();
return REG_ADC_VIN.vbus;
}
uint8_t bq25731::get_adc_vbat(void){
get_adc_vsysvbat();
return REG_ADC_VOUT.vbat;
}
And same basic i2c request:
#define ADC_VBUS_PSYS 0x26
uint16_t bq25731::get_adc_vbuspsys(void){
dev.i2c_read(ADC_VBUS_PSYS, readBuf, 2);
REG_ADC_VIN.vbus = readBuf[1];
REG_ADC_VIN.psys = readBuf[0];
return (readBuf[1] << 8) + readBuf[0];
}
#define ADC_VSYS_VBAT 0x2C
uint16_t bq25731::get_adc_vsysvbat(void){
dev.i2c_read(ADC_VSYS_VBAT, readBuf, 2);
REG_ADC_VOUT.vsys = readBuf[1];
REG_ADC_VOUT.vbat = readBuf[0];
return (readBuf[1] << 8) + readBuf[0];
}
Output:
ADC_Option: 0x2043 Input Voltage Voltage: 5376mV SYS Voltage Voltage: 768mV Battery Voltage: 768mV
