Hello everyone!
I would appreciate any help on this subject - i can read and write BQ25120A registers without a problem, but whatever value i write into Fast Charge Control Register it is allways charging with approx 15mA (measured with DMM)...
Did anyone manage to set higher current and how?
To be clear - i can write any value into Fast Charge Control Register and that value will be stored - checked by reading the register...
Lower values like 10mA also do not work...
Many thanks,
Josip
Hello again!
I have made a more precise measurement, charging current is in fact 11mA (do not believe it is important, but just in case...)
one of the codes i used to test this is :
#define BQ25120A_FAST_CHG_AFTER_BOOT 176 //charging current = 120mA
#define BQ25120A_ILIM_UVLO_CTRL_AFTER_BOOT 56 //BUVLO = 3V
#include "Nicla_System.h"
constexpr auto printInterval { 1000ul };
float voltage = -1.0f;
int x;
void setup(){
Serial.begin(115200);
for (const auto timeout = millis() + 2500; millis() < timeout && !Serial; delay(250));
nicla::begin(); // Initialise library
nicla::leds.begin(); // Start I2C connection to LED driver
initBQ25120A();
nicla::leds.setColor(blue);
}
void loop(){
static auto updateTimestamp = millis();
if (millis() - updateTimestamp >= printInterval) {
updateTimestamp = millis();
float currentVoltage = nicla::getCurrentBatteryVoltage();
if(currentVoltage != voltage){
voltage = currentVoltage;
Serial.print("\nVoltage: ");
Serial.println(voltage);
} else {
Serial.print(".");
}
auto operatingStatus = nicla::getOperatingStatus();
switch(operatingStatus) {
case OperatingStatus::Charging:
nicla::leds.setColor(255,100,0); // Yellow
break;
case OperatingStatus::ChargingComplete:
nicla::leds.setColor(green);
// This will stop further charging until enableCharging() is called again.
nicla::disableCharging();
break;
case OperatingStatus::Error:
nicla::leds.setColor(red);
break;
case OperatingStatus::Ready:
nicla::leds.setColor(blue);
break;
default:
nicla::leds.setColor(off);
break;
}
}
}
void initBQ25120A(){
Serial.println("BQ25120A Register Map Values after BOOT...");
printBQ25120ARegisterMap();
setBQ25120ARegisterMapValues();
Serial.println("BQ25120A Register Map Values after SETUP");
printBQ25120ARegisterMap();
}
void setBQ25120ARegisterMapValues(){
nicla::setBatteryNTCEnabled(false);
nicla::configureChargingSafetyTimer(ChargingSafetyTimerOption::ThreeHours);
BQ25120A().writeByte(BQ25120A_ADDRESS, BQ25120A_ILIM_UVLO_CTRL, BQ25120A_ILIM_UVLO_CTRL_AFTER_BOOT);
BQ25120A().writeByte(BQ25120A_ADDRESS, BQ25120A_FAST_CHG, BQ25120A_FAST_CHG_AFTER_BOOT);
}
void printBQ25120ARegisterMap(){
uint8_t value = 0;
/*
// Register Map
#define BQ25120A_STATUS 0x00
#define BQ25120A_FAULTS 0x01
#define BQ25120A_TS_CONTROL 0x02
#define BQ25120A_FAST_CHG 0x03
#define BQ25120A_TERMINATION_CURR 0x04
#define BQ25120A_BATTERY_CTRL 0x05
#define BQ25120A_SYS_VOUT_CTRL 0x06
#define BQ25120A_LDO_CTRL 0x07
#define BQ25120A_PUSH_BUTT_CTRL 0x08
#define BQ25120A_ILIM_UVLO_CTRL 0x09
#define BQ25120A_BATT_MON 0x0A
#define BQ25120A_VIN_DPM 0x0B
*/
Serial.println("*********** BQ25120A Register Map Values ***********");
value = BQ25120A().readByte(BQ25120A_ADDRESS, BQ25120A_STATUS );
Serial.print("BQ25120A_STATUS = ");
Serial.println(value);
value = BQ25120A().readByte(BQ25120A_ADDRESS, BQ25120A_FAULTS );
Serial.print("BQ25120A_FAULTS = ");
Serial.println(value);
value = BQ25120A().readByte(BQ25120A_ADDRESS, BQ25120A_TS_CONTROL );
Serial.print("BQ25120A_TS_CONTROL = ");
Serial.println(value);
value = BQ25120A().readByte(BQ25120A_ADDRESS, BQ25120A_FAST_CHG );
Serial.print("BQ25120A_FAST_CHG = ");
Serial.println(value);
value = BQ25120A().readByte(BQ25120A_ADDRESS, BQ25120A_TERMINATION_CURR );
Serial.print("BQ25120A_TERMINATION_CURR = ");
Serial.println(value);
value = BQ25120A().readByte(BQ25120A_ADDRESS, BQ25120A_BATTERY_CTRL );
Serial.print("BQ25120A_BATTERY_CTRL = ");
Serial.println(value);
value = BQ25120A().readByte(BQ25120A_ADDRESS, BQ25120A_SYS_VOUT_CTRL );
Serial.print("BQ25120A_SYS_VOUT_CTRL = ");
Serial.println(value);
value = BQ25120A().readByte(BQ25120A_ADDRESS, BQ25120A_LDO_CTRL );
Serial.print("BQ25120A_LDO_CTRL = ");
Serial.println(value);
value = BQ25120A().readByte(BQ25120A_ADDRESS, BQ25120A_PUSH_BUTT_CTRL );
Serial.print("BQ25120A_PUSH_BUTT_CTRL = ");
Serial.println(value);
value = BQ25120A().readByte(BQ25120A_ADDRESS, BQ25120A_ILIM_UVLO_CTRL );
Serial.print("BQ25120A_ILIM_UVLO_CTRL = ");
Serial.println(value);
value = BQ25120A().readByte(BQ25120A_ADDRESS, BQ25120A_BATT_MON );
Serial.print("BATT_MON = ");
Serial.println(value);
value = BQ25120A().readByte(BQ25120A_ADDRESS, BQ25120A_VIN_DPM );
Serial.print("BQ25120A_VIN_DPM = ");
Serial.println(value);
Serial.println("****************************************************");
Serial.println("");
}