I'm new to IMUs. We created code to initialize and use the BMI160 inertial measurement unit very similar to Bosch's driver offered in github.
I can read gyroscope and magnetometer data, but the accelerometer data freezes most of the time. That is, it repeats the same, or very similar values, all the time.
My code goes like this:
0) Initialize the IMU and Magnetometer. All three sensors power mode set to normal. ACC_CONFIG = 0x28, ACC_RANGE = 0x03.
1) Press a button on our device
2) Start reading the DATA register every 10 ms, for 10 seconds, storing it in an array in RAM.
3) After reading and storing the data, print it to our DEBUG serial output (i.e. printf)
... and so on. I verified that these data values are actually received in our I2C interface.
Any ideas of what can cause the frozen data?
Thanks in advance.
Solved! Go to Solution.
Thank you for your message.
After power on BMI160 accel and gyro will be in suspend mode by default waiting for your configuration. You can write value of 0x11 to command register 0x7E to bring accel to normal mode. You need to wait for at least 5ms and then you can write value of 0x15 to command register 0x7E to bring gyro to normal mode. You also need to wait at least 80ms for gyro to be stablized before you perform I2C read or write action. Then you can read register 0x03 to see if you get the value of 0x14 back. If yes, then it means both accel and gyro are in normal mode.
Now you can read data registers from 0x12 to 0x17 6 bytes for accel data continuously. The accel data should not be frozen no matter if BMI160 is stationary or in motion. Maybe you read wrong registers which are constant or maybe the accel is still in suspend mode because you did not wait long enough after you write value of 0x11 to command register 0x7E.
I have a peculiar problem problem with your chip BMI160.After
configuring it via I2c iam able to read the chip ID of 0x1d , but the chip
does not go to normal mode and the accelerometer value always return zero. Can
you provide some inputs , My code is attched below. Iam using nrf52 connected to
BMI160 via pins 12 and 13 for I2c