BMI160 & STM32 Strange Behaviour - Sensor Succesfully Inits but Accel and Gyro Reads are always zero

Hello,

I am trying to use the BMI160 sensor with my STM32G474 Nucleo board. I am working over I2C. I wrote the Read - Write and DelayUS functions.

I successfully init the sensor. It returns 0 as "rslt", which means everything is fine according to this library. After that, when I configure Accel and Gyro, rslt still returns 0.

But I am constantly reading 0 from gyro and accel. Also, sometimes I get -7 error after configuring Accel and Gyro. I guess my ODR/BW settings for Accel and Gyro are not working. How can I set the correct ODR/BW and datarate?

I'm posting the code I'm using, below. In addition to the standard BMI160 library, I write two more codes to be able to use library:

  • common_porting = Holds I2C Read - Write and DelayUs functions
  • bmi160_wrapper = The code I wrote to use Bosch's standard library with common_porting. In the Main() function, I call the BMI160_init() function directly in this code, for example, to initialize the BMI160.

commom_porting.c:

 

bmi160_wrapper.c:

 

 

 

BMI160.rar
8.56MB
8 replies