Bosch Sensortec Community

    cancel
    Showing results for 
    Search instead for 
    Did you mean: 

    Problem when setting bmi160 in suspend mode

    Problem when setting bmi160 in suspend mode

    TTN
    New Poster

    Hi everyone,

    I want to truning bmi160 from normal mode to suspend mode for reduce current and set suspend mode to normal mode when i need to capture data.
    Now I can set  bmi160 in to  normal mode and get data, but when i  alway get BMI160_E_COM_FAIL(-2) when set normal mode to suspend mode.Any suggestion to solve this problem?

    static void Spi_sensor_init( void ) {
    
        /* You may assign a chip select identifier to be handled later */
        s_spi_bmi160_sensor.id = 0 ;
        s_spi_bmi160_sensor.interface = BMI160_SPI_INTF ;
        s_spi_bmi160_sensor.read = Spi_read_transfer ;
        s_spi_bmi160_sensor.write = Spi_write_transfer ;
        s_spi_bmi160_sensor.delay_ms = Spi_delay_ms ;
    		
        int8_t rslt = BMI160_OK ;
    		rslt = bmi160_init( &s_spi_bmi160_sensor ) ;
    	
    	  if ( rslt == 0 ) {
    		  SEGGER_RTT_printf( 0,"Get bmi160 data success ! \n", rslt ) ; 	
    		} // if
              else 
    		SEGGER_RTT_printf( 0,"Error : Get bmi160 data fail ! \n", rslt ) ; 
    
        /* After the above function call, accel_cfg and gyro_cfg parameters in the device 
        structure are set with default values, found in the datasheet of the sensor */
    
        rslt = BMI160_OK ;
    
        /* Select the Output data rate, range of accelerometer sensor */
        s_spi_bmi160_sensor.accel_cfg.odr = BMI160_ACCEL_ODR_100HZ ;
        s_spi_bmi160_sensor.accel_cfg.range = BMI160_ACCEL_RANGE_2G ;
        s_spi_bmi160_sensor.accel_cfg.bw = BMI160_ACCEL_BW_NORMAL_AVG4 ;
        
        /* Select the power mode of accelerometer sensor */
        s_spi_bmi160_sensor.accel_cfg.power = BMI160_ACCEL_NORMAL_MODE ;
    
        /* Select the Output data rate, range of Gyroscope sensor */
        s_spi_bmi160_sensor.gyro_cfg.odr = BMI160_GYRO_ODR_100HZ ;
        s_spi_bmi160_sensor.gyro_cfg.range = BMI160_GYRO_RANGE_2000_DPS ;
        s_spi_bmi160_sensor.gyro_cfg.bw = BMI160_GYRO_BW_NORMAL_MODE ;
    
        /* Select the power mode of Gyroscope sensor */
        s_spi_bmi160_sensor.gyro_cfg.power = BMI160_GYRO_NORMAL_MODE ;
    
        /* Set the sensor configuration */
        rslt = bmi160_set_sens_conf( &s_spi_bmi160_sensor ) ;
    
        /* Select the power mode */
        s_spi_bmi160_sensor.accel_cfg.power = BMI160_ACCEL_NORMAL_MODE ;
        s_spi_bmi160_sensor.gyro_cfg.power = BMI160_GYRO_NORMAL_MODE ;  
    
        /*  Set the Power mode  */
        rslt = bmi160_set_power_mode( &s_spi_bmi160_sensor ) ;
        nrf_delay_ms( 10 ) ; // delay_10ms
        
    } // Spi_sensor_Sensor_init()
    
    static void Spi_sensor_poweroff( void ) {
    
          int8_t rslt = BMI160_OK ;
    
          s_spi_bmi160_sensor.accel_cfg.power = BMI160_ACCEL_SUSPEND_MODE ;
          s_spi_bmi160_sensor.gyro_cfg.power = BMI160_GYRO_SUSPEND_MODE ;
          rslt = bmi160_set_power_mode( &s_spi_bmi160_sensor ) ;
          SEGGER_RTT_printf(0,"bmi160_set_power_mode rslt = %d\n", rslt);
    
    }

     

    3 REPLIES 3

    BSTRobin
    Community Moderator
    Community Moderator

    Hello TTN,

    BMI160_ E_ COM_ Fail stands for communication failure. You could check if SPI waveform when you executed setting sensor mode function?

    Hi Robin~

    Thanks for your reply.

    I found that in some situation the api will return error code(-2).

    After avoid this situation the return is 0.

    But the sensor didn't turn in the suspend mode, I still can get data from the spi.
    How can i set the sensor in a mode, that consume lowest current and can be wakeup?

    BSTRobin
    Community Moderator
    Community Moderator

    Hello TTN,

    How do you judge that the sensor mode is not configured correctly?
    After you configure the sensor, dump all registers to see if the register configuration is the value you expected.

    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