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.

BQ35100: How to switch between SEALED/UNSEALED/FULL ACCESS modes?

Part Number: BQ35100


Hello,

I am working on BQ35100 to get battery level.
I have bq35100 integrated with stm32l071 on a board. I am NOT USING BQ STUDIO to calibrate bq35100.
In order to get battery level I need to calibrate the device and for calibration I have to write commands in UNSEALED MODE.
This is the code I am trying - (Ref - slua640b)

void enterCalibrationMode(void) {
printf("Entering Calibration Mode.\n");
send_subCommand(0x00, 0x2D); //Enable Calibration mode
send_subCommand(0x00, 0x81); //Enter Calibration mode
send_subCommand(0x00, 0x00);
send_Command(0x00);
unsigned char buffer[2] = { 0x00, 0x00 };
_delay_cycles(10000);
I2C_read(buffer, 2);
do {
printf("%x\n", buffer[1]);
printf("Gauge is not in Calibration mode.\n");
} while ((buffer[1] & 0x10) != 0x10);
printf("Gauge is in Calibration mode.\n");
}

These steps always return "Gauge is not in Calibration mode".

I am not sure that the device is in UNSEALED MODE.

So, I want to know -
1. How to check BQ35100 is currently in which mode i.e. SEALED/UNSEALED/FULL ACCESS?
2. How to switch between different modes? Are there some keys to switch between them? If Yes, then how can I get them?

  • the control register bits sec1, sec0 when set to 01 indicate that the gauge is in unsealed mode. if you haven't changed anything on the df, the default unseal key is 0x0414 0x3672 and the default full access key is 0xffff 0xffff with both bytes in both commands sent back to back.
  • Hi Batt,

    Thanks for the response. Reading the control register bits sec1, sec0 returns 01 indicating that gauge is in full access mode (As per reference manual). Also INITCOMP bit is set indicating that initialization is complete.

    But when I try writing to registers (as per I mentioned in the code above) it always shows error i.e. NO ACKNOWLEDGE from GAUGE even when I try to write into DF it also shows same error. I tried writing with different time duration but same error everytime. 

    Also, In which register I should write 0xffff 0xffff?

    If I write 0xffff, 0xffff on 0x41D0, 0x41D2 address (Full Unseal Step1, Full Unseal Step2) respectively, it shows error. 

    So, basically I am unable to write. Please help with these problems.

    Regards,

    Sakshi

  • write it to 0x00.
  • Hi Batt, 

    Thank you for your reply.

    Tried writing this..

    HAL_I2C_Mem_Write(&hi2c2, 0xAA, 0x00, I2C_MEMADD_SIZE_8BIT, (uint8_t *)keys, 4, 200);  // keys[2] = {0x0414, 0x3672}

    Did not worked.

    then tried writing..

    HAL_I2C_Mem_Write(&hi2c2, 0xAA, 0x00, I2C_MEMADD_SIZE_16BIT, (uint8_t *)key1, 2, 200); //key1 = 0x0414

    HAL_I2C_Mem_Write(&hi2c2, 0xAA, 0x00, I2C_MEMADD_SIZE_16BIT, (uint8_t *)key2, 2, 200); //key2 = 0x3672

    Tried with different time durations.

    But everytime it returns ERROR.

    Can you help me with this please.

    Note - HAL_I2C_Mem_Write Format -: HAL_I2C_Mem_Write(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint16_t MemAddress, uint16_t MemAddSize, uint8_t *pData, uint16_t Size, uint32_t Timeout)

    Regards,

    Sakshi

  • You need to write it in little endian back to back. For unseal you need to write 0x1404 to 0x00 immediately followed by 0x7236 to 0x00. Then follow that by writing 0xffff to 0x00 twice to get into full access mode.
  • Hi Batt,

    Tried as you said in your last reply but still unable to resolve my problem.

    Is there anything I am missing?

    This is my unsealed mode code -

    void gauge_unsealed()
    {
    	HAL_Delay(1000);
    	HAL_I2C_Mem_Write(&hi2c2, 0xAA, 0x00, I2C_MEMADD_SIZE_8BIT, (uint8_t *)&key1, 2, 300); //key1 = 0x1404
    	HAL_Delay(10);
    	HAL_I2C_Mem_Write(&hi2c2, 0xAA, 0x00, I2C_MEMADD_SIZE_8BIT, (uint8_t *)&key2, 2, 300); //key2 = 0x7236
    	HAL_Delay(10);
    }
    
    void read_status()
    {
    	HAL_I2C_Mem_Read(&hi2c2, 0xAB, 0x00, I2C_MEMADD_SIZE_8BIT, &buf[1], 1, 200); 
            HAL_Delay(10);
            HAL_I2C_Mem_Read(&hi2c2, 0xAB, 0x01, I2C_MEMADD_SIZE_8BIT, &buf[0], 1, 200);
    }

    Reading 0x00 and 0x01 returns 0x2080.

    Tried reading - 

    HAL_I2C_Mem_Read(&hi2c2, 0xAB, 0x0000, I2C_MEMADD_SIZE_16BIT, buf, 2, 200);

    This returns 0x2000.

    So, basically nothing works.
    Now, can you please help me with this? I am still unable to switch in unseal mode.
    Can you tell me where I am going wrong?

  • #1: You can check bits SEC1 and SEC0 in CONTROL_STATUS.

    SEC1, SEC0 (Bit 14,13): Indicates which SECURITY mode the device is in
    0, 0 = Reserved
    0, 1 = Full Access
    1, 0 = Unsealed
    1, 1 = Sealed

    #2: Please follow the instructions from 12.2.1. The default keys are 0x0414 and 0x3672 (unseal), 0xFFFF and 0xFFFF (full access)

    Your code looks correct so from the abstraction level that you provided, it looks like you are performing the correct steps.

    If the gauge doesn't switch to unsealed, something interferes with the actual data transfer of the keys. It is important that the keys are the only data that is transferred and that they are written consecutively exactly as described in the TRM.

    To debug this further I suggest using an I2C protocol analyzer and checking the actual data on the physical bus. As the sequence is fairly short, a DScope that captures SCL and SDA will probably do as an alternative.