SparkFun Forums 

Where electronics enthusiasts find answers.

Have questions about a SparkFun product or board? This is the place to be.
By BoredBSEE
#193244
I was porting the code from the Arduino library for the Battery Babysitter to a PIC32 for a project of mine, and I noticed a problem. Figured I'd create an account here and post my findings and maybe save someone the time/trouble I went through.

Anyways, if you look in SparkFunBQ27441.cpp you'll see this bit in enterConfig():
while ((timeout--) && (!(status() & BQ27441_FLAG_CFGUPMODE)))

But in exitConfig() you'll see this:
while ((timeout--) && ((flags() & BQ27441_FLAG_CFGUPMODE)))

Turns out exitConfig() has it right. You're checking flags() for CFGUPMODE, not status(). Change the enterConfig() line to use flags(). Find a document from TI called sluuac9.pdf to see why. Sparkfun guys - if you read this, check it out and please make the change to your Arduino library.

Yours,
BoredBSEE