Correct way to configure BMI160.

Hi Bosch sensortec community

I am using BMI160 IMU in 4 wire SPI in my application. The way I am following to configure the sensor is like below: (indicated here)

void Initialize_BMI160(void)
{
struct bmi160_dev sensor;
/* You may assign a chip select identifier to be handled later */
sensor.id = 0;
sensor.interface = BMI160_SPI_INTF;
sensor.read = user_spi_read;
sensor.write = user_spi_write;
sensor.delay_ms = user_delay_ms;

/*****************************************************/
rslt = bmi160_init(&sensor);
/* 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 */
/*********Configuring the acc/gyro*************/
// int8_t rslt = BMI160_OK;

/* Select the Output data rate, range of accelerometer sensor */
sensor.accel_cfg.odr = BMI160_ACCEL_ODR_1600HZ;
sensor.accel_cfg.range = BMI160_ACCEL_RANGE_2G;
sensor.accel_cfg.bw = BMI160_ACCEL_BW_NORMAL_AVG4;
/* Select the Output data rate, range of Gyroscope sensor */
sensor.gyro_cfg.odr = BMI160_GYRO_ODR_3200HZ;
sensor.gyro_cfg.range = BMI160_GYRO_RANGE_2000_DPS;
sensor.gyro_cfg.bw = BMI160_GYRO_BW_NORMAL_MODE;

/* Select the power mode */
sensor.accel_cfg.power = BMI160_ACCEL_NORMAL_MODE;
sensor.gyro_cfg.power = BMI160_GYRO_NORMAL_MODE;

/* Set the Power mode */
rslt = bmi160_set_power_mode(&sensor);

/* Set the sensor configuration */
rslt = bmi160_set_sens_conf(&sensor);
}

 

I don't see the proper behaviour on MISO pin. The questions I have:

1- Did I configure the sensor correctly? In other words, do I need any other registers to be configured?

2- The SPI clock for my application is 750 kHz. Is there a restriction for the SPI clock?

I'd appreciate it if you can help me!

Thanks

Saber

Best reply by Harvey
The variable is set to zero first, then the chip ID is read.

The chip ID is fixed and cannot be set.

o_o
View original
4 replies
Resolved