This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

BQ27427: Implementing fuel gauge on STM32, anyone have sample driver C code?

Part Number: BQ27427

Tool/software:

Looking to implement this BQ27427 on an STM32 based system, anyone have driver C code as a nice basis to start?  Not that I can't write it all myself and figure it out, but why re-invent the wheel if someone has stuff who's willing to share.  Thanks!

  • Hello Steven, 

    I believe this is the closest thing we have to what you are looking for. Please see this link for Linux Driver for BQ27XXX devices. 

    Regards, 

    Jonny. 

  • Jonny,

    Thank you.  That did help me get started.  I appreciate it.

    I have the EVM dev board and I've got a 620mAh battery connected to it.  And it's responding.  And I was following the technical reference manual for the BQ27427 (I believe) and I was having some issues.

    Success: I did have it read the Device Firmware, the document says 0x0202 and thats what I read out of it.  I get temperature, battery voltage and current all correctly reporting. 

    Fail: when I read the Device ID I get 0x6C08 which seems wrong.  And there is no state of charge.  All the states of charge are all 0's. 

    Any ideas what I could try?

    Steve

  • Hello Steve, 

    Before referring to the SOC reported by the gauge, you should configure the gauge for your application. Additionally, how are you trying to read the SOC? 

    Regards, 

    Jonny. 

  • Jonny,

    Thanks for replying.  I agree I need to configure the gauge for my application.  I might have not done that properly.  But it was weird the device ID was always reporting 0x6c08.  I figured out how to do a hard reset of the device and that was what solved it. 

    I did 2 control unseals in a row, then CFG Update, waited for the CFGUPMODE flag to get set.  Then did a hard reset, waited for that flag to clear.  Then did a control seal. 

    After that the device ID was reporting correctly and the SOC was what I expected based on defaults in the datasheet. 

    Prior to this, reading any of the capacity registers they were all 0, which I was surprised with.  FW version was good, batt voltage was good, but device ID was not and all the capacities were 0.  Did a hard reset (as described above) and it was fine.  Not sure what made it mad, or put it in that mode, but I think I have it working well now.

    Steve

  • Hello Steven, 

    Thank you for the update here. Please let us know if you have any more questions. 

    Regards, 

    Jonny.