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.

Control Register through I2C (BQ27510)

Other Parts Discussed in Thread: BQ27510

Hello,

I am having trouble accessing the control register on the BQ27510.

The datasheet mentions writing a subsequent 2 byte command after sending the command for the control register.  So my I2C code is as follows:

Start, wait for confirm, send 7 bit address with LSB cleared, wait for confirm, send 0x00 (register), confirm, send 0x00 (lsb), confirm, send 0x00(msb), confirm, Stop.
I believe this part is correct so far.

I then try to read and I get 0x0010 back - which suggests the device is unsealed and in SLEEP mode - which makes sense as the battery is fully and constantly on charge.
My read sequence is as per the datasheet with the first write for the register then read back with the LSB set. 

However, I get 0x0010 back regardless of the command I send.  If I want to read the firmware, hardware or chemical IDs, they also come back 0x0010.
Can anyone suggest where I am going wrong? 

Also, I tried sending the command 0x0020 to seal the device to see if I got 0x6010 on return but that failed as well.

  • Jon, can you provide the actual command sequence when other commands (not 0x0000) are used?What is the I2C address you are using?

    thanks

    Ming

  • The other commands are sent in reverse byte order.  So the command for hardware version would be sent:

    Start, 0xAA, 0x00, 0x03, 0x00, Stop

    Followed by a read - but as I stated before this returns the same value as any other.  I tried the bytes the other way around as well but to no avail.

    The I2C address I'm using is 0xAA, clearing the lower bit for write, setting it for read.

    I can read all the other registers fine, voltage, temperature, etc.

  • Jon,

     

    I don't see anything wrong with this sequence. Can you capture the actual I2C using i2C sniffer? Have you tried another board?

     

    Ming

     

     

     

  • Hi,

    I have solved this issue now.  I needed to place a small delay in between the write and subsequent read command.

    Cheers.

  • I have a question about the "command code" on the datsheet for this part.   The document I have on the bq27510 shows the "command code" for the control register 0x00/0x01, the "command code for the AtRate is 0x02/0x03 etc.  The example above to read the hardware version uses just the 0x00 value for the "command code" and this would make sense to me if the command code was just 0x00 and not 0x00/0x01.   Is the command code listed as 0x00/0x01 because either 0x00 or 0x01 can be used?  This would make the LSB a "don't care" if that is the case.

    See page 8 of this datasheet:

     http://focus.ti.com/lit/ds/symlink/bq27510.pdf

    Thanks,

    Doug

  • Hi Doug,

    From memory, I believe you only need to use 0x00 because the address pointer is auto-incremented when you write your data bytes.

     

    Jon

  • One more question...

    After the sequence you described "Start, 0xAA, 0x00, 0x03, 0x00, Stop", do you need to send the read command 0xAB before the actual read or just follow this by the read?

    Thanks,

    Doug

  • That sequence is the write command and it will need to be followed by a delay then the read command which is completely separate.

    See the data sheet for more information but in this example it would be:


    Write: Start, 0xAA, 0x00, 0x03, 0x00, Stop

    Delay

    Read: Start, 0xAA, 0x00, Start, 0xAB,  (read byte 1), (read byte 2), Stop

  • Jon,

    I think I have the reads working both standard and sub commands and the following doc was also helpful along with your advice:

    http://focus.ti.com.cn/cn/lit/an/slua467a/slua467a.pdf

     

    I want to put the bq27510 in unsealed mode but I have not found the sequence in the datasheets or in the forum.  Can you provide the sequence to put the 27510 in unsealed mode and do you also need delays in the write sequence? 

    Thanks again for your help.

    Doug

  •  

    step 1:

    If I read the control register I get:

    AA 00 00 00    AA 00    AB 00 70 (read 0x700, indicates device is sealed)

     

    Step 2:

    I then write the following sequence to unseal the device:

    AA 00 00 00  AA 00    AA 00 00

     

    After step 2, if I read back as described in the first step, I read the same value (0x700).

    Doug

  • Hi John,

    Iam using BQ27510 fuel guage with customised board and i dont have EV 2300. Please help me how i start using and communicate with the BQ27510 to read battery remaining capacity.

  • Doug,

    That is the status register and it is read only.  Writing a zero to it will not unseal the device.

    There's more information on pages 15-19 of the datasheet but effectively, you have to write the unseal keys (found in data flash) to the control register in sequence to unlock the device.

    I remember being unsuccessful in my attempt to try this (the values returned for the default keys seemed to differ to those in the datasheet and neither set worked) but perhaps you will be able to figure this out.

  • Deepu,

    You will most likely need to read up on I2C communication for your microprocessor then the datasheet for the BQ27510 - page 30 gives details on how to communicate with the fuel gauge.

    Jon

  • 3438.i2c.pdf

    Hi Jon,

    Thank you for your reply. Iam attaching a document where in an example of reading the cell voltage is given. i have tried to implement that example and Iam not able to view output in the oscilloscope at the SDA pin. Iam completely new to I2C protocol. Please suggest me if any modifications has to be done to the code i have written.

    #include "msp430xG46x.h"

    unsigned char Data;                     // Pointer to TX data
    unsigned char TXByteCtr;

    void main(void)
    {
      WDTCTL = WDTPW + WDTHOLD;                 // Stop WDT
      P3SEL |= 0x06;                            // Assign I2C pins to USCI_B0
      UCB0CTL1 |= UCSWRST;                      // Enable SW reset
      UCB0CTL0 = UCMST + UCMODE_3 + UCSYNC;     // I2C Master, synchronous mode
      UCB0CTL1 = UCSSEL_2 + UCSWRST;            // Use SMCLK, keep SW reset
      UCB0BR0 = 11;                             // fSCL = SMCLK/11 = 95.3kHz
      UCB0BR1 = 0;
      UCB0I2CSA = 0xAA;                         // Slave Address is 048h
      UCB0CTL1 &= ~UCSWRST;                     // Clear SW reset, resume operation
      IE2 |= UCB0TXIE+UCB0RXIE;                 // Enable TX interrupt

      

       UCB0CTL1 |= UCTR + UCTXSTT;             // I2C TX, start condition
        __bis_SR_register(GIE);                 // Enter LPM0 w/ interrupts
                                                // Remain in LPM0 until all data
                                                // is TX'd
        while (UCB0CTL1 & UCTXSTP);             // Loop until STP is TX'd
     
    }

     #pragma vector = USCIAB0TX_VECTOR
    __interrupt void USCIAB0TX_ISR(void)
    {
         UCB0TXBUF =   0xAA;                    // Load I2C address
         UCB0TXBUF =   0x08;                    // Load guage command
         UCB0TXBUF =   0xAB;                     // Load I2C address
         Data = UCB0RXBUF;
        __bic_SR_register_on_exit(CPUOFF);      // Exit LPM0
    }

     

  • For MSP430 sample code using I2C (or HDQ) talking to our fuel gauges, refer to SLVA413A:

    http://focus.ti.com/analog/docs/litabsmultiplefilelist.tsp?literatureNumber=slva413a&docCategoryId=1&familyId=412

     

  • Thanks again for the help.  After looking closer at the doc, I do not think I need to unseal it, I was looking at it because I had the scope on it and could easily debug the I2c.

    Doug