Bosch Sensortec Community

    Showing results for 
    Search instead for 
    Did you mean: 

    BMI270 Config file load problem

    BMI270 Config file load problem


    I'm using I2C bus to access BMI270 sensor with STM32H7 board. The chip ID of the sensor is read correctly from the register 0x00 with 0x24. I followed the steps of initialization, write_reg(0x7c,0x00), write_reg(0x59, 0x00), as the datasheet written. And these steps look alright since the functions return "HAL_OK" status.

    Then I used a for loop to burst write the config file that I found in BMI270 API into register 0x5E. I wrote 1 byte from the config file array everytime in the for loop. The writing status of the function I was using is "HAL_OK" as well, which seems alright. Then I wrote 0x01 into the register again like the datasheet said. However, when I read 0x5E (where I loaded the congif file) to check if the config file was burst written correctly, it looked completely different.

    Could you please help me with this problem? Any guidence would be appreciated!

    Here is my code

    HAL_StatusTypeDef return_value;
    uint8_t addr = 0x7c;
    uint8_t addr1 = 0x59;
    uint8_t addr2 = 0x5e;
    uint8_t addr2_sub = 0x5e;
    uint8_t addr_chk = 0x21;
    uint8_t val[1];
    val[0] = 0x00;
    uint8_t val_1[1];
    val_1[0] = 0x01;
    uint8_t return_addr_chk[1];
    // write_reg(0x7c, 0x00)
    return_value = HAL_I2C_Mem_Write(&hi2c1, (uint16_t)(BMI270_address), (uint16_t)addr, 1, val, 1, HAL_MAX_DELAY);

    if(return_value == HAL_OK){
        // write_reg(0x59, 0x00)   Burst write the config file
        return_value = HAL_I2C_Mem_Write(&hi2c1, (uint16_t)BMI270_address, (uint16_t)addr1, 1, val, 1, HAL_MAX_DELAY);
        if(return_value ==HAL_OK){
            for(uint16_t i=0; i<sizeof(bmi270_config_file); i++){
                return_value = HAL_I2C_Mem_Write(&hi2c1, (uint16_t)BMI270_address, (uint16_t)addr2_sub, 1, &bmi270_config_file[i], 1, HAL_MAX_DELAY);
                 if(return_value != HAL_OK){


    return_value = HAL_I2C_Mem_Write(&hi2c1, (uint16_t)(BMI270_address), (uint16_t)addr1, 1, val_1, 1, HAL_MAX_DELAY); // write_reg(0x59,0x01)
    if(return_value != HAL_OK){
    return_value = HAL_I2C_Mem_Read(&hi2c1, (uint16_t)(BMI270_address|0x01), addr_chk, 1, return_addr_chk, 1, HAL_MAX_DELAY); // read INTERNAL_STATUS

    uint8_t config_file_check[8192];
    return_value = HAL_I2C_Mem_Read(&hi2c1, (uint16_t)(BMI270_address|0x01), 0x5e, sizeof(bmi270_config_file), config_file_check, sizeof(bmi270_config_file), HAL_MAX_DELAY); // check if the file loaded correctly

    7 REPLIES 7



    I tried using burst write to load the config file 32 bytes at once, but it failed. It looks like my MCU only supports the write/read length of 2 bytes and one byte. So I have two question:

    1. Is it okay if I use burst write to load the config file two bytes at once in the while loop? 

    2. Could you please expain the example code you replied in this post before? Here's the part that confuses me:


    Does this mean you wrote both "0x00" and "file_count_" into INIT_ADDR_0 every time when looping? 

    A supplyment of my last question:

    I tried writing two bytes into the register INIT_ADDR_0. (e.g I wrote 0xc8, 0x2e) However, the data I read from INIT_ADDR_0 is always 0x24 and 0x21. This is also resulted when I test other registers like INIT_CTRL other than INIT_ADDR_0.

    Also, if I wrote one byte into INIT_ADDR_0, only the last 6 bit of the data can be write/read. (I wrote 10001000 into INIT_ADDR_0. But I read 001000 from it after that.)

    Community Moderator
    Community Moderator

    Hello Saa, 


    First, your system supports burst read operation. 

    If yes, could you follow below code? 

    config_size = sizeof(bmi2xx_config_file);
    file_count = 0;

    while (config_size > 0)


    byte reg_data[32];
    // Begin I2C communication with provided I2C address
    // Done writting, end the transmission

    // Requests the required number of bytes from the sensor
    Wire.requestFrom((int)BMI270_ADDR, (int)32);

    // Reads the requested number of bytes into the provided array

    uint16_t i = 0;

    for (i = 0; (i < 32 ) && Wire.available(); i++)
    reg_data[i] =; // This is for the modern Wire library
    Serial.print(" ");


    filepos += 32;
    file_count += 1;
    config_size -= 32;