diff --git a/src/drivers/magnetometer/st/iis2mdc/iis2mdc.cpp b/src/drivers/magnetometer/st/iis2mdc/iis2mdc.cpp index 9a295d100d0..b1ae7ec23d0 100644 --- a/src/drivers/magnetometer/st/iis2mdc/iis2mdc.cpp +++ b/src/drivers/magnetometer/st/iis2mdc/iis2mdc.cpp @@ -64,9 +64,11 @@ int IIS2MDC::init() write_register(IIS2MDC_ADDR_CFG_REG_B, OFF_CANC); write_register(IIS2MDC_ADDR_CFG_REG_C, BDU); - _px4_mag.set_scale(100.f / 65535.f); // +/- 50 Gauss, 16bit + _px4_mag.set_scale(0.0015f); // 1.5 mGauss/LSB (datasheet) - ScheduleDelayed(20_ms); + // Poll at the 100 Hz ODR on a fixed interval so the rate does not drift with + // the time spent reading the sensor. + ScheduleOnInterval(10_ms); return PX4_OK; } @@ -95,11 +97,9 @@ void IIS2MDC::RunImpl() } } else { + // No new sample yet; expected occasionally when polling at the data rate. PX4_DEBUG("not ready: %u", status); - perf_count(_comms_errors); } - - ScheduleDelayed(10_ms); } uint8_t IIS2MDC::read_register_block(SensorData *data) diff --git a/src/drivers/magnetometer/st/iis2mdc/iis2mdc.h b/src/drivers/magnetometer/st/iis2mdc/iis2mdc.h index 40da40469d6..9982d66fa3e 100644 --- a/src/drivers/magnetometer/st/iis2mdc/iis2mdc.h +++ b/src/drivers/magnetometer/st/iis2mdc/iis2mdc.h @@ -46,7 +46,7 @@ // IIS2MDC Definitions #define IIS2MDC_WHO_AM_I 0b01000000 -#define IIS2MDC_STATUS_REG_READY 0b00001111 +#define IIS2MDC_STATUS_REG_READY 0b00001000 // Zyxda: X, Y and Z all have new data // CFG_REG_A #define COMP_TEMP_EN (1 << 7) #define MD_CONTINUOUS (0 << 0)