05-30-2022 04:39 PM
Hello
In my code, the initalization is done successfully through bmi270_init api (returns BMI2_OK). Afterwords, I do the ACC and Gyro initalization using the steps found in examples (BMI270-Sensor-API/bmi270_examples/accel_gyro) I call the following function after interface_init and bmi270_init.
nt8_t BMI270Driver::set_accel_gyro_config()
{
/* Status of api are returned to this variable. */
int8_t rslt;
/* Assign accel sensor to variable. */
uint8_t sensor_list[2] = { BMI2_ACCEL, BMI2_GYRO };
/* Structure to define accelerometer and gyro configuration. */
struct bmi2_sens_config config[2];
/* Configure the type of feature. */
config[ACCEL].type = BMI2_ACCEL;
config[GYRO].type = BMI2_GYRO;
tr_debug("111");
/* Get default configurations for the type of feature selected. */
rslt = bmi270_get_sensor_config(config, 2, &dev);
error_codes_print_result(rslt);
tr_debug("222");
/* Map data ready interrupt to interrupt pin. */
rslt = bmi2_map_data_int(BMI2_DRDY_INT, BMI2_INT1, &dev);
error_codes_print_result(rslt);
if (rslt == BMI2_OK)
{
/* NOTE: The user can change the following configuration parameters according to their requirement. */
/* Set Output Data Rate */
config[ACCEL].cfg.acc.odr = BMI2_ACC_ODR_200HZ;
/* Gravity range of the sensor (+/- 2G, 4G, 8G, 16G). */
config[ACCEL].cfg.acc.range = BMI2_ACC_RANGE_2G;
/* The bandwidth parameter is used to configure the number of sensor samples that are averaged
* if it is set to 2, then 2^(bandwidth parameter) samples
* are averaged, resulting in 4 averaged samples.
* Note1 : For more information, refer the datasheet.
* Note2 : A higher number of averaged samples will result in a lower noise level of the signal, but
* this has an adverse effect on the power consumed.
*/
config[ACCEL].cfg.acc.bwp = BMI2_ACC_NORMAL_AVG4;
/* Enable the filter performance mode where averaging of samples
* will be done based on above set bandwidth and ODR.
* There are two modes
* 0 -> Ultra low power mode
* 1 -> High performance mode(Default)
* For more info refer datasheet.
*/
config[ACCEL].cfg.acc.filter_perf = BMI2_PERF_OPT_MODE;
/* The user can change the following configuration parameters according to their requirement. */
/* Set Output Data Rate */
config[GYRO].cfg.gyr.odr = BMI2_GYR_ODR_200HZ;
/* Gyroscope Angular Rate Measurement Range.By default the range is 2000dps. */
config[GYRO].cfg.gyr.range = BMI2_GYR_RANGE_2000;
/* Gyroscope bandwidth parameters. By default the gyro bandwidth is in normal mode. */
config[GYRO].cfg.gyr.bwp = BMI2_GYR_NORMAL_MODE;
/* Enable/Disable the noise performance mode for precision yaw rate sensing
* There are two modes
* 0 -> Ultra low power mode(Default)
* 1 -> High performance mode
*/
config[GYRO].cfg.gyr.noise_perf = BMI2_POWER_OPT_MODE;
/* Enable/Disable the filter performance mode where averaging of samples
* will be done based on above set bandwidth and ODR.
* There are two modes
* 0 -> Ultra low power mode
* 1 -> High performance mode(Default)
*/
config[GYRO].cfg.gyr.filter_perf = BMI2_PERF_OPT_MODE;
am_util_delay_ms(10);
tr_debug("333");
/* Set the accel and gyro configurations. */
rslt = bmi270_set_sensor_config(config, 2, &dev);
error_codes_print_result(rslt);
}
tr_debug("444");
rslt = bmi270_sensor_enable(sensor_list, 2, &dev);
error_codes_print_result(rslt);
return rslt;
}
I get an error " Invalid Accel-Gyro configuration error. It occurs when there is a error in accel and gyro" " configuration registers which could be one among range, BW or filter performance in reg address 0x40 "
What whould make the EVENT register raise the acc_and_gyr_err flag although I use the same API functions and example code?
Solved! Go to Solution.
06-01-2022 05:16 PM
Hi YahyaTawil,
Do you mean you get return value BMI2_E_ACC_GYR_INVALID_CFG after calling bmi270_sensor_enable()function?
06-03-2022 09:13 AM - edited 06-03-2022 09:16 AM
Hello BSTRobin
It is throughing the error BMI2_E_ACC_GYR_INVALID_CFG in bmi270_set_sensor_config. Keep in mind please, that bmi270_init returns BMI2_OK.
bmi270_sensor_enable returns BMI2_OK.
06-13-2022 02:26 PM
06-23-2022 11:42 AM
Hi YahyaTawil,
You could debug into bmi270_set_sensor_config() function and find where is the code executed with error?
By the way, did you write the C++ driver code you used? The official driver is the C code.