Hello Bosch sensortec community I am using BMI160 IMU in my application. I need continuous read of accel/gyro sesnors. I have configured the sesnors' parameters like indicated in Bosch github can be found here. With 4 wire SPI interface protocol, I could read the chip_id which is 0xD1 that means the protocol works fine. For reading the sensors' data without sensortime as mentioned earlier, I am using the function in an infinite loop, while(1). /* To read both Accel and Gyro data */
bmi160_get_sensor_data((BMI160_ACCEL_SEL | BMI160_GYRO_SEL), &accel, &gyro, &sensor); The problem arose is that for when I change the sensor, either in translational or rotational direction, all registers will change. For example, if I rotate the sensor, the accel->x will change. Do you have any idea where the problem is? Thanks in advance! Saber ............................................................................................................................ For your reference, I have included the way I am getting the data: while(1)
{
/* To read both Accel and Gyro data */
bmi160_get_sensor_data((BMI160_ACCEL_SEL | BMI160_GYRO_SEL), &accel, &gyro, &sensor);
} Also, the user_SPI_read: int8_t user_spi_read(uint8_t dev_id, uint8_t reg_addr, uint8_t *reg_data, uint16_t length)
{
int8_t rslt = BMI160_OK; /* Return 0 for Success, non-zero for failure */
/* Communicate len number of bytes: if RX - the procedure sends 0x00 to push bytes from slave*/
SPI_BMI160_BEGIN;
reg_addr = reg_addr | 0x80; // For read operation, the reg_addr should be ORed with 0x80.
SPI_BMI160_TX(reg_addr);
__delay_cycles(15); //after write operation, at least 2 micro-seconds is required for the next operation.
//SPI_BMI160_RX(rslt);
for (i = 0; i < length; i++)
{
SPI_BMI160_TX(0); /* Possible to combining read and write as one access type */
SPI_BMI160_RX(*reg_data++); /* Store pData from last pData RX */
}
SPI_BMI160_END;
return rslt;
} user_SPI_write: int8_t user_spi_write(uint8_t dev_id, uint8_t reg_addr, uint8_t *reg_data, uint16_t length)
{
int8_t rslt = BMI160_OK; /* Return 0 for Success, non-zero for failure */
SPI_BMI160_BEGIN;
reg_addr = reg_addr & 0x7F;
SPI_BMI160_TX(reg_addr); // For write operations, the register should be ANDed with 0x7F.
__delay_cycles(15);
/* Communicate len number of bytes: if TX - the procedure doesn't overwrite pData */
for (i = 0; i < length; i++)
{
SPI_BMI160_TX(*reg_data++);
}
SPI_BMI160_END;
return rslt;
}
... View more