Bosch Sensortec Community

    cancel
    Showing results for 
    Search instead for 
    Did you mean: 
    SOLVED

    bmi270 PWR_CONF and PWR_CTRL value

    XudanMorris-Wei
    New Poster

    bmi270 PWR_CONF and PWR_CTRL value

    Hello everyone:

    New to the community. Running into an interesting behavior with BMI270, wondering if any one has an answer there. 

    Using BMI270, able to read the CHIP-ID correctly. After soft-reset and wait for 1000ms, reading the value of registers, PWR_CONF and PWR_CTRL, both comes back as 0x00, while it is supporsed to be 0x03 for PWR_CONF. Intersting is if read PWR_CTRL first then read PWR_CONF, it comes back as0x03 and 0x00. Any idea why?

    Attaching some source code here for reference.

    void device_imu_bmi270_reset()
    {
    uint8_t value = 0xFF;

    mcu_spi_io_pkg bmi270_spi_io_pkg;
    bmi270_spi_io_pkg.bytesToSendReceive = 2;
    bmi270_spi_io_pkg.p_tx_buffer = tx_buffer;
    bmi270_spi_io_pkg.p_rx_buffer = rx_buffer;
    bmi270_spi_io_pkg.devnum = MCU_SPI_DEV_BMI270;

    tx_buffer[0] = BMI270_COMMAND_WRITE | BMI270_REG_CMD;
    tx_buffer[1] = BMI270_COMMAND_RESET;
    mcu_spi_io(&bmi270_spi_io_pkg);

    printLog("BMI270 resetting\r\n");
    sl_sleeptimer_delay_millisecond(1000);

    //device_imu_bmi270_read_register_onebyte(BMI270_REG_PWRCONF); //0x03
    device_imu_bmi270_read_register_onebyte(BMI270_REG_PWRCTRL); //0x00
    device_imu_bmi270_read_register_onebyte(BMI270_REG_PWRCONF); //0x03

    //simply switch these two above lines, the output gets correct  

    }

    The read function is defined as 

    uint8_t device_imu_bmi270_read_register_onebyte(uint8_t addr)
    {
    mcu_spi_io_pkg bmi270_spi_io_pkg;
    bmi270_spi_io_pkg.bytesToSendReceive = 3;
    bmi270_spi_io_pkg.p_tx_buffer = tx_buffer;
    bmi270_spi_io_pkg.p_rx_buffer = rx_buffer;
    bmi270_spi_io_pkg.devnum = MCU_SPI_DEV_BMI270;

    tx_buffer[0] = BMI270_COMMAND_READ | addr;
    tx_buffer[1] = BMI270_DUMMY_DATA; // 16 bit protocol. dummy byte needed before read actual data
    tx_buffer[2] = BMI270_DUMMY_DATA; // dummy
    mcu_spi_io(&bmi270_spi_io_pkg); // send data to BMI270


    printLog("Read byte is 0x%02x\r\n",rx_buffer[2]);
    return rx_buffer[2];
    }

     

    Thanks for your inputs

     

    1 REPLY 1
    etracer
    Established Member

    Re: bmi270 PWR_CONF and PWR_CTRL value

    After the soft reset the BMI270 will be back in I2C mode and you'll have to get it to switch back to SPI mode before attempting to read the registers. I ususlly just toggle the CS low for 10ms but you can also perform a "dummy" register read to get it to switch. I also add a small delay after switching before reading the first register to give it time to switch but this isn't documented in the datasheet so I don't know if it's required (but probably a good idea).

    Icon--AD-black-48x48Icon--address-consumer-data-black-48x48Icon--appointment-black-48x48Icon--back-left-black-48x48Icon--calendar-black-48x48Icon--center-alignedIcon--Checkbox-checkIcon--clock-black-48x48Icon--close-black-48x48Icon--compare-black-48x48Icon--confirmation-black-48x48Icon--dealer-details-black-48x48Icon--delete-black-48x48Icon--delivery-black-48x48Icon--down-black-48x48Icon--download-black-48x48Ic-OverlayAlertIcon--externallink-black-48x48Icon-Filledforward-right_adjustedIcon--grid-view-black-48x48IC_gd_Check-Circle170821_Icons_Community170823_Bosch_Icons170823_Bosch_Icons170821_Icons_CommunityIC-logout170821_Icons_Community170825_Bosch_Icons170821_Icons_CommunityIC-shopping-cart2170821_Icons_CommunityIC-upIC_UserIcon--imageIcon--info-i-black-48x48Icon--left-alignedIcon--Less-minimize-black-48x48Icon-FilledIcon--List-Check-grennIcon--List-Check-blackIcon--List-Cross-blackIcon--list-view-mobile-black-48x48Icon--list-view-black-48x48Icon--More-Maximize-black-48x48Icon--my-product-black-48x48Icon--newsletter-black-48x48Icon--payment-black-48x48Icon--print-black-48x48Icon--promotion-black-48x48Icon--registration-black-48x48Icon--Reset-black-48x48Icon--right-alignedshare-circle1Icon--share-black-48x48Icon--shopping-bag-black-48x48Icon-shopping-cartIcon--start-play-black-48x48Icon--store-locator-black-48x48Ic-OverlayAlertIcon--summary-black-48x48tumblrIcon-FilledvineIc-OverlayAlertwhishlist