Hi,
Here is what you can do to verify your code.
In your initialization function, you can configure BMI160 as below.
Write value of 0x11 to register 0x7E; // set ACC to normal mode, by default ACC is +/-2g full scale range and 100Hz ODR Delay 5ms; // the max time of 3.8ms from datasheet Write value of 0x15 to register 0x7E; // optional, set GYR to normal mode, by default GYR is +/-2000dps full scale range and 100Hz ODR Delay 80ms; // the max time of 80ms from datasheet
unsigned char value = read register 0x03;
If (value == 0x14) then it means both ACC and GYR are in normal mode now
In your loop function for example you can burst read BMI160 data registers from 0x0C to 0x17 total 12 bytes in one single I2C transaction at 1s time interval. Then you can plot Ax, Ay, Az values on the terminal to see if you can get about 16384 integer when you place any axis pointing to sky and about -16384 integer when any axis is pointing to ground.
If yes, then you can change BMI160 ACC full scale range to +/-8g by writing the value of 0x08 to register 0x41 and then repeat the above steps. You should get about 4096 integer when you place any axis pointing to sky and about -4096 integer when any axis is pointing to ground.
Thanks.
... View more