11-06-2019 10:17 AM
Hi all,
I'm trying to get BMM150 magnetometer data @100Hz using the BMI270 as master device, but when I configure the sensor in forced mode I only get the first measure, the next measures are all equals.
This is my configuration code for BMM150:
int8_t BMM150_DEVICE_Init() {
int8_t rslt = BMM150_OK;
// ----> BMM150 initialization over I2C (BMI270 aux)
bmm150_dev.dev_id = BMM150_DEFAULT_I2C_ADDRESS;
bmm150_dev.intf = BMM150_I2C_INTF;
bmm150_dev.read = bmm150_read;
bmm150_dev.write = bmm150_write;
bmm150_dev.delay_ms = bmm150_delay_ms;
rslt = bmm150_init(&bmm150_dev);
if(rslt!=BMM150_OK) {
goto exit;
}
// <---- BMM150 initialization over I2C (BMI270 aux)
//perform_self_tests(&bmm150_dev);
// ----> Configuration
bmm150_dev.settings.preset_mode = BMM150_PRESETMODE_REGULAR;
rslt = bmm150_set_presetmode(&bmm150_dev);
if(rslt!=BMM150_OK) {
goto exit;
}
bmm150_dev.settings.pwr_mode = BMM150_FORCED_MODE;
rslt = bmm150_set_op_mode(&bmm150_dev);
// <---- Configuration
exit:
if( rslt == BMM150_OK ) {
systemStatus.bmm150_initialized = 1;
} else {
systemStatus.bmm150_initialized = 0;
}
return rslt;
}
void bmm150_delay_ms(uint32_t msec) {
HAL_Delay(msec);
}
int8_t bmm150_read(uint8_t dev_id, uint8_t reg_addr, uint8_t *read_data, uint16_t len) {
return bmi2_read_aux_man_mode(reg_addr, read_data, len, &bmi270_dev);
}
int8_t bmm150_write(uint8_t dev_id, uint8_t reg_addr, uint8_t *write_data, uint16_t len) {
return bmi2_write_aux_man_mode(reg_addr, write_data, len, &bmi270_dev);
}
Is there something to be changed to get it working correctly?
Thank you,
Walter
Solved! Go to Solution.
11-06-2019 11:41 AM - edited 11-06-2019 11:44 AM
I finally found the solution to the problem: the BMM150 was correctly configured, but the BMI270 was not.
It is very important to set
config.cfg.aux.fcu_write_en = BMI2_ENABLE;
in the configuration of the auxiliar sensor, this option is really badly documented (no cited in BMM150 datasheet, no explained in BMI270 datasheet):
// ----> Initialize BMM150
struct bmi2_sens_config config;
// Magnetometer in manual mode for configuration
config.type = BMI2_AUX;
config.cfg.aux.aux_en = BMI2_ENABLE;
config.cfg.aux.manual_en = BMI2_TRUE;
config.cfg.aux.i2c_device_addr = BMM150_DEFAULT_I2C_ADDRESS; // I2C address of BMM150
config.cfg.aux.read_addr = BMM150_CHIP_ID_ADDR; // Address of the first read address
config.cfg.aux.man_rd_burst = BMI2_AUX_READ_LEN_0; // Size of manual burst read
// Set the configurations
rslt = bmi2_set_sensor_config(&config, 1, &bmi270_dev);
if (rslt != BMI2_OK)
goto exit;
rslt = BMM150_DEVICE_Init();
if (rslt != 0)
goto exit;
// Automatic burst read
config.type = BMI2_AUX;
config.cfg.aux.aux_en = BMI2_ENABLE;
config.cfg.aux.manual_en = BMI2_FALSE;
config.cfg.aux.i2c_device_addr = BMM150_DEFAULT_I2C_ADDRESS; // I2C address of BMM150
config.cfg.aux.read_addr = BMM150_DATA_X_LSB; // Address of the first read address
config.cfg.aux.offset = 0;
config.cfg.aux.aux_rd_burst = BMI2_AUX_READ_LEN_3; // Size of auto burst read
config.cfg.aux.fcu_write_en = BMI2_ENABLE;
config.cfg.aux.odr = BMI2_AUX_ODR_100HZ;
// Set the configurations
rslt = bmi2_set_sensor_config(&config, 1, &bmi270_dev);
if (rslt != BMI2_OK)
goto exit;
// <---- Initialize BMM150
I suggest to add a configuration example for BMM150 in the BMI270 README.
Walter
05-12-2022 12:41 PM - edited 05-12-2022 01:52 PM
Hi @Myzhar ,
I too got the same problem. Still I'm trying in Arduino with ESP32-C3 Module, can you please share me the code which you are using for Acc, Gyro, Mag data of BMI270 shuttle board. I'm trying to resolve this problem so many days but no use.
Any help would be very thankful.