PMIC get/setInputCurrentLimit not setting correctly?

Hi guys, just gone through this thread and now understand problem and solution for increasing the input current limit from default. However...
How about the opposite problem? I have a battery which lasts much longer with a consistent load (without spikes), so want to limit the current to 20mA. I cannot understand why the following code does not work:

SYSTEM_MODE(MANUAL);
PMIC pmic;
STARTUP( setupPMIC() );

void setupPMIC(){
    pmic.begin();
    pmic.setInputCurrentLimit(20);
}

void setup() {}
void loop() {}

Still getting around 250mA current draw!
Please can someone tell me what I'm missing here?

Also, I noticed in the bq24195 datasheet has:

ā€“ Input Current Limit: 100 mA, 150 mA, 500 mA, 900 mA, 1.2 A, 1.5 A, 2 A and 3 A

Does this mean there are only predefined values which can be set?
Many thanks in advance.

@dan.s,

setInputCurrentLimit(x) sets the maximum current for the VUSB (Vin) source.
In other words, your pmic.setInputCurrentLimit(20); call would "attempt to" limit the USB source to 20 mA, not the Battery.
Whenever the Boron requires More than 20 mA, the Battery would be used to supplement the USB source. However, 20mA isn't a valid setting.

The values are defined in spark_wiring_power.cpp, beginning at line #243.

/*******************************************************************************
 * Function Name  : setInputCurrentLimit
 * Description    : Sets the input current limit for the PMIC
 * Input          : 100,150,500,900,1200,1500,2000,3000 (mAmp)
 * Return         : 0 Error, 1 Success
 *******************************************************************************/

Also, are you sure that 250 mA isn't going into your battery?

If you explain your Case in more detail we might can help with suggestions.

Sorry, I should have statedā€¦
By battery I mean our much larger Li-SOCI2 battery supplying VIN.
The method is to use the smaller 2000mAh LiPo battery by default to handle spikes when powering up and connecting over cellular. Most of the time, we will be in deep sleep < 1mA.
However, our tests are showing that VIN is being used up to about 250mA as the primary power source, when really all we want is to have it trickle charging the LiPo (as Li-SOCI2 batteries last much longer without spikes).

As you can see, 20mA would be optimum.
But we also tried pmic.setInputCurrentLimit(100); with no luck.

You can try this workaround for the 100 mA to "stick", found here :

void setup() {
    detachInterrupt(LOW_BAT_UC);
    // Delay for up to two system power manager loop invocations
    delay(2000);
    // Change PMIC settings
    PMIC pmic;
    pmic.setInputCurrentLimit(100);
}

I guess in a perfect world, you would use setChargeCurrent(20) and physically switch the Li-COSl2 source occasionally, but the minimum offset is 512 mA (hardware defined IIRC), from Line # 588

* Function Name  : setChargeCurrent
* Description    : The total charge current is the 512mA  + the combination of the
                    current that the following bits represent

I remember a few discussions attempting to perform something similar to your Use Case.
I don't remember the solution(s) though.

Thank you that workaround does the job! Shame the lowest we can go is 100mA, but itā€™s better than nothing.
I tested with both STOP mode sleep and DEEP sleep and in both modes worked fine, waking from the former did not need to be recalled, but it does take a few seconds after waking from deep sleep to enter setup and call it. Unfortunately we cannot use this in STARTUP so I guess we will have to live with the fact it will draw 250mA for a few seconds every time it wakes up from deep sleep.

Can you tell me what detachInterrupt(LOW_BAT_UC); does, and will we need to catch anything because of using it?

@dan.s, This post contains the majority of what I "know" about the issue:

Ok thanks for your help.
Still quite confused on what it does exactly though. Maybe there will be a docs update which will explain soon :crossed_fingers:

In light of this, weā€™re now thinking of actually just inserting a resistor in series (100 ohms seems to work nicely) to restrict the current, and not even update the firmware.

Just an update - simply using a resistor in series to restrict the current did not work, in fact it made the battery life worse. So back to the drawing boardā€¦