I'm having a sort of an issue with power settings on a Muon.
Scenario:
1- I remove the battery of a Muon to start fresh
2- replace the battery
3- set the power config via SystemPowerConfiguration.powerSourceMinVoltage(5080)
4- read via pmic->getInputVoltageLimit()
5- settings are not set
Now if I:
1- I remove the battery of a Muon to start fresh
2- replace the battery
3- set the power config via pmic API
4- set the power config via SystemPowerConfiguration.powerSourceMinVoltage(5080)
5- read via pmic->getInputVoltageLimit()
6- settings are set
What am I doing wrong? Maybe a config set with power manager cannot be read with pmic calls?
How would I verify that settings are correct with power manager?
Thanks!
set power config using SystemPowerConfiguration
SystemPowerConfiguration *powerConfig;
uint16_t currentLimit = pmic->getInputVoltageLimit();
logp.info("Current input voltage limit: %u mV. Attempting to update to %u mV.", currentLimit, desiredLimit);
System.setPowerConfiguration(SystemPowerConfiguration()); // To restore the default configuration before making changes
powerConfig->powerSourceMaxCurrent(900)
.powerSourceMinVoltage(5080)
.batteryChargeCurrent(1024)
.batteryChargeVoltage(4208)
.feature(SystemPowerFeature::PMIC_DETECTION);
int res = System.setPowerConfiguration(*powerConfig);
Log.info(" * * * * * power config API MODE setPowerConfiguration=%d", res);
currentLimit = pmic->getInputVoltageLimit();
if (currentLimit == desiredLimit)
Log.warn("Attempt %d: Failed to update input voltage limit. Current limit: %u mV.", attempt, currentLimit);
set power config using pmic api:
powerConfig->feature(SystemPowerFeature::DISABLE);
System.setPowerConfiguration(*powerConfig);
WITH_LOCK(*this)
{
pmic->begin();
pmic->setInputVoltageLimit(5080);
pmic->setInputCurrentLimit(150);
pmic->setChargeVoltage(4208);
// pmic->setChargeCurrent(0, 0, 1, 0, 0, 0);
pmic->setChargeCurrent(10);
pmic->enableCharging();
pmic->enableDPDM();
pmic->enableBuck(); // Neat trick to force System Power Manager to run DPDM.
}
"Failure" logs via SystemPowerConfiguration:
0000004042 [power] INFO: * * * * * power config API MODE setPowerConfiguration=0
0000004053 [power] INFO: Current input voltage limit: 4360 mV. Attempting to update to 5080 mV.
0000004671 [power] INFO: * * * * * power config API MODE setPowerConfiguration=0
0000005679 [power] WARN: Attempt 1: Failed to update input voltage limit. Current limit: 4360 mV.
0000006355 [power] INFO: * * * * * power config API MODE setPowerConfiguration=0
0000007359 [power] WARN: Attempt 2: Failed to update input voltage limit. Current limit: 4360 mV.
0000007990 [power] INFO: * * * * * power config API MODE setPowerConfiguration=0
0000009010 [power] WARN: Attempt 3: Failed to update input voltage limit. Current limit: 4360 mV.
0000009626 [power] INFO: * * * * * power config API MODE setPowerConfiguration=0
0000010630 [power] WARN: Attempt 4: Failed to update input voltage limit. Current limit: 4360 mV.
0000011273 [power] INFO: * * * * * power config API MODE setPowerConfiguration=0
0000012278 [power] WARN: Attempt 5: Failed to update input voltage limit. Current limit: 4360 mV.
0000012281 [power] ERROR: Failed to update input voltage limit to 5080 mV after 5 attempts.
Success logs if I use both modes to set power settings:
0000003370 [power] INFO: Current input voltage limit: 4360 mV. Attempting to update to 5080 mV.
0000004057 [power] INFO: * * * * * power config PMIC MODE
0000004711 [power] INFO: * * * * * power config API MODE setPowerConfiguration=0
0000004814 [power] INFO: Input voltage limit successfully updated to 5080 mV on attempt 1.
Thanks