User's Manual

UMXXX
The LIS2MDL is based on AMR technology (anisotropic magneto-resistive): a set pulse is
needed to set an initial operating condition; a reset pulse may be used to enable the
compensation of the intrinsic magnetic offset.
If intrinsic offset compensation is disabled, there is no reset pulse. The set pulse
can be generated at power-on only (Set_FREQ=1), or every 64
measurements
(Set_FREQ=0).
If intrinsic offset compensation is enabled, set and reset pulses are generated
alternately on consecutive samples. After the set pulse, the measured output is
magnetic field H + offset; after the reset pulse, the measured output is H – offset
o In continuous mode, the device will automatically average consecutive
measurements to compensate for the offset, the output will be equal to the
magnetic field H: output = [( H+offset) + (H-offset)]/2 = H.
o In single-shot mode, the host microcontroller has to perform the average of
two consecutive measurements. The averaged measurements must be
near in time for the compensation to be effective.
When intrinsic offset compensation is done, the residual offset is in the range of +/-60
mgauss, and the dependency on temperature is +/-0.3 mgauss/degC.
LIS2MDL EXTRINSIC OFFSET (HARD IRON) COMPENSATION
Hard-iron distortion is a constant offset added to the magnetic field to be measured. Hard-
iron distortion may be caused by near-by ferromagnetic materials or high currents. This
offset can be computed by the host microcontroller by analyzing the output of the
magnetometer (see DT0059 on ellipsoid or sphere fitting, also see MotionMC software
library in X-CUBE-MEMS1 software expansion on st.com). When it is available, this offset
can be programmed in specific registers (OFFSET_X_REG_H/L, OFFSET_Y_REG_H/L,
OFFSET_Z_REG_H/L) so that it is automatically subtracted by LIS2MDL.
LIS2MDL INTERRUPT GENERATION
The LIS2MDL magnetometer sensor can be configured to generate interrupt when output
data (before or after the subtraction of hard-iron offset) exceeds a programmed threshold
(INT_THS_H/L_REG) in the positive or negative direction. Comparisons can be enabled
independently for each axis (XIEN, YIEN, ZIEN flags). When the output data is above the
positive threshold, the corresponding flag is set (P_TH_S_X/Y/Z). When the output data is
below the negative threshold, the corresponding flag is se t(N_TH_S_X/Y/Z).
A specific interrupt can be generated if there is a measurement range overflow at the
internal ADC.