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.

I2C com to bq27425

I have read and reread the bq27425 spec.  Unfortunately, I still do not understand what byte values I send to command() the chip.  I tried to specify the I2C pattern for some of the bq27425 commands, but I could not.  The issue is the value of the 3rd byte on diagram (a) [pg 25] for a command().  Is it a "Don’tCare" or the first byte of the subcommand?

Given my confusion and the fact that I need to actually write code to interface to the chip, I would like someone to create two diagrams patterned after the ones on page 25,.  But the new diagrams will have the specific byte values for a Command()/Control_Status read and a Command()/Set_Hibernate write.  These new diagrams will replace the generic ones on page 25 and should enable me to understand the com to the chip. 

In short, I am asking someone to replace the generic diagrams on page 25 with the set of diagrams required to implement the two cases I ask about.  The new diagrams should, therefore, be a clear indication (using actual byte values) of what my code will send the chip for the two commands.

Thank you and regards,

Richard Brisk

Kopin Inc.

  • Hello Richard,

    Pls see attached app note that describes i2C communication for our single cell gauges. It should clarify your questions. i have also attached sample code which you can reference for communicating with our gauge. i hope this helps.

    1856.FlashStream028_bundle (2).zip

    slua467b[1]_using 2c communication with the bq275xx.pdf

    thanks

    Onyx

  • Onyx,

    Thank you for your response to my question.  However, I have seen that bq275xx document before.  My understanding is that the 275xx uses commands that have one byte.  Whereas, the bq27425's commands are two bytes long.  That difference is part of my confusion on the structure of the read and write commands to the 27425 chip. 

    For instance, it would be very helpful if you would detail the bit pattern for the following sequence of commands.

    • Set Hibernate
    • Report status
    • Set Hibernate
    • Report status

    Thank you for your help,

    Richard Brisk

  • In addition, Richard found some documentation indicating S/W is available. Please let us know if this S/W is published somewhere.


    The bq27425 spec says that “Most data block locations, however, are only accessible in UNSEALED mode by use of the bq27425 evaluation
    software or by data block transfers.” This clearly implies the existence of TI written SW. How can I get that SW?

    Thanks!
  • Hello Richard,

    Please check: https://github.com/aneeshv/linux-bq27xxx/blob/t-ambient-fix/drivers/power/bq27x00_battery.c

    Let me know if this meets your requirement.

    Thanks,

    Kang Kang

  • Onyx,

    Thank you for sending the PDF "slua467b[1]_using 2c communication with the bq275xx.pdf." It was exactly the explanation I was looking to find.

    Now that I understand the basic commands, I am grappling with the Extended Data Commands, such as "DataFlashClass," "DataFlashBlock," "BlockData," etc. Is there a similarly enlightening document that describes the Extended Data Commands?
  • Onyx,

    I eventually did figure out how to send an Extended Data Command.  So, forget my earlier question regarding Extended Data Commands.

    I do wish to communicate to TI, however, that I think the bq47245 specification is the most poorly written document of its kind I have ever read.  It takes the equivalent education and parsing of words worthy of a PhD in English literature to figure out what is being described.  It is that poor a description of the commands.  I would be glad to give examples of where it falls short of being even a reasonable explanation, but I doubt that TI would care or even listen.

    But as for your help, I do thank you.

    Best regards,

    RABrisk

  • Hi Richard
    I do apologize for the poor documentation on how the commands ought to be sent as described in the data sheet and I am currently having our systems engineers review it. Believe me, it is also challenging for me as well reading through given that I am not a software engineer myself. I would appreciate if you can give examples of where it falls short and also post on here how you were able to resolve your issues for the sake of other users of the chip. I will forward your feed back to the necessary personal when you send it and will try to have our systems engineer get the data sheet updated. We are definitely interested in listening.

    thanks and best regards
    Onyx
  • Forwarded from Richard :

     

    Although I read and write to the “standard” register area of the bq27425 without any problems, I experience problems when reading and writing to the “Block Data” area. 

     

    Looking for some documentation on this.

  • Hello Thomas,

    What is your sequence when writing block data? Do you enter cfg update mode first?

    Thanks,

    Kang Kang

  • Kang,

    Thank you for your email.  In response, I put a copy of my code below.

    HAL_StatusTypeDef    ReadDataBlock (uint8_t CLASS, uint8_t OFFSET, uint8_t *u8ReadBuffer)
    {
       HAL_StatusTypeDef      i2c_result = HAL_OK;
       uint8_t                            u8LocalWriteBuffer[10] = {BLOCKDATACONTROL, 0x00}; //set for 1st I2C Transmit

          //Send BLOCKDATACONTROL+0x00 (i.e., 0x61, 0x00) to enable BlockData() to access NVM and RAM
          if ((i2c_result = I2C_Master_Transmit(&hi2c1, 0xAAAA, u8LocalWriteBuffer, 2, BQ27425_TIMEOUT)) == HAL_OK)
          {
              //Put the Class and Offset, of the BlockData to be accessed, into  BlockData and BlockData+1
              u8LocalWriteBuffer[0] = DATACLASS;     //DATACLASS = 0x3E;
              u8LocalWriteBuffer[1] = CLASS;              //e.g., 0x52;
              u8LocalWriteBuffer[2] = DATABLOCK;    //BLOCK = 0x3F;
              u8LocalWriteBuffer[3] = (OFFSET / 32);  //BLOCK_#: 0, 1, 2, etc.;


               i2c_result = I2C_Master_Transmit(&hi2c1, 0xAAAA, u8LocalWriteBuffer, 2, BQ27425_TIMEOUT);
              i2c_result = I2C_Master_Transmit(&hi2c1, 0xAAAA, &u8LocalWriteBuffer[2], 2, BQ27425_TIMEOUT);
             
              i2c_result = I2C_Master_Receive (&hi2c1, 0xAAAB, u8ReadBuffer, 32, BQ27425_TIMEOUT);

  • Hello Richard,

    I do not see any command to enter CFG Update. I just see the initialization for the block data.

    Thanks,
    Kang Kang
  • I have added a SET_CFG_UPDATE command at the top of my commands that read the BLOCKDATA area. First, it does not help (nor should it since I am only trying to read the BLOCKDATA area not change it.
    Second, I should have explained the problem. It is that I read the Second BLOCKDATA area even though I write a 0x00 into DATABLOCK (0x3F).

    I can correctly read that second BLOCKDATA by putting 0x01 into DATABLOCK. But for some reason, when I put 0x00 into DATABLOCK (0x3F), I still read that second block. That is VERY STRANGE and VERY WRONG.

    Richard Brisk
  • Ah, I think I understand the problem.

    Please write something to 3E first and then 00 or 01 to 3F.

    Thanks,
    Kang Kang
  • No so. That is not my mistake. I say that because I am writing to 0x3E first. In my trial, I am trying to fetch the Op Config information. I use Op Config because I know the answer should be 0x89f8. So, I first write 0x52 to command 0x3E. Writing 0x52 tells the chip that I want to see Gas Gauging STATE information. I then write 0x00 into 0x3F. I have done that as a separate write or as a second data byte in the write to command 0x3E. But in either case, when I read locations 0x40 - 0x5F, it always shows me the 0x01th block not the 0x00th block. What is going on?
  • Hello Richard,

    Let me research this problem. I will get back to you soon after I have tried this on the EVM.

    Thanks,
    Kang Kang
  • Hello Richard,

    Here is my sequence.

    I send 0x00 to 0x61 - Enables Block Data Control

    I send 0x52 to 0x3E, then 0x00 to 0x3F

    I then read 32 bytes from 0x40

    You will not get OpConfig as the first two bytes, it will be in the middle. Bytes 6 and 7.

    Let me know if this helps.

    Thanks
  • I have reviewed my code many times over. It looks correct. So, I wonder if my problem is that I wrote bank 0x01 into bank 0x00 when I was testing my code that changes the BLOCKDATA and writes it to ROM.
    I have done a HARD_RESET, but that not change the ROM. So, the fact that the results are the same does not tell me if I clobbered bank 0x00.

    My question to you is, is there any way to "virgin-ize" the chip?
  • Thanks for your help with the bq27425 communication.  As of now, I am all set.

    Thanks again,

    Richard Brisk

  • New Problem, not sure if it should have its own thread.

    I2C locking up.

    The problem is that there are times when the bq27425 “locks up.” The specifics of the lock up are that it first returns a BUSY to some I2C comm (reason unknown). Following that BUSY, it returns a TIMEOUT to all future I2C comms to read or write to the chip.

    This is a major, major problem since the chip becomes totally unresponsive to all requests for information.

    The problem is made severe because there does not seem to be a way to unlock the chip. At least, to date I have not found a way to unlock the chip. Even sending a Hard Reset does not bring it back to life. I urgently need a solution to the problem.

    Is this a known issue? Is there a work-around?

    Thanks!

  • Hello Thomas,

    Do you mean the I2C is getting clock stretched?

    Could you send some waveforms of when the I2C "locks" up.

    Thanks
  • I am back from vacation. Working on getting trace images of problem. In the mean time, I have another question.
    My question is about reading the "StateOfHealth( ): 0x20/0x21", "OperationConfiguration( ): 0x3a/0x3b" and "DesignCapacity( ): 0x3c/0x3d" words? The register addresses of these three words are beyond the 32 byte "standard" block of registers. It is unlikely that the design wants me to read from register 0 to register 62 rather than 0 to 32. Additionally, reading to register 62 gives me bogus information above the 32nd byte.
    So my question is
    Q: Do I read those three words in a 62 block read that includes "Temperature( ): 0x02/0x03", "Voltage( ): 0x04/0x05" etc.?
    Or, do I read them in a special block read?

    If the answer is the latter, please explain the details of that read.

    Thank you,
  • Thanks for the suggestion. I will try it. But, I had a Delay(100) there previously and it did not change the result. Nevertheless, I will try it and report back to you.

    Thanks
  • It worked. You are terrific. Thanks so much.
  • I have some SHOW STOPPING ISSUES around the State Of Charge 0x1c/0x1d value I get when polling the bq27425 I am using.  I need good answers quickly.

    Here are my concerns:

    1) It takes 5 minutes to get a reading for the State Of Charge that is not 0%. 

    Is that expected? 

    Can anything be done to get results more quickly?

    2)  When the State Of Charge 0x1c/0x1d value does appear it is always 100%.  That cannot be correct.  What is going on?

    3)  The State Of Charge 0x1c/0x1d value never shows any value other than 0% if the battery is discharging (ie, average current and average power are both negative).  What is going on with that?  And, how can I correct that problem?

    These are SHOW STOPPING ISSUES.  Please respond.

  • Hello Richard,

    I am not sure why it is taking 5 minutes.

    Could you gather some waveforms?

    Are you doing any type of polling in your MCU/processor code?

    If SOC is not changing, try to look at the BAT_DET bit in Flags().
  • Kang,

    Thank you for your prompt answer. 

    With regard to your comment about the BAT_DET flag:  We have chosen to inform the bq that the battery is installed by sending a BAT_INSERT command to the chip.  We do this because our hardware does not implement the auto detect capability.

    With regard to the 5 min problem:  I am still looking into this issue.  I will send you more information when I have something to send.

    Thank you again,

    Richard Brisk

  • A follow up question
  • Assuming that I do not have the 5 min problem, I am still faced with the problem that the StateOfCharge % and the SOH Percent only read either 0 or 100%, never a true value. What things might cause that misleading situation?