English
Language : 

LSM303AH Datasheet, PDF (23/82 Pages) –
LSM303AH
Functionality
4.1.2
4.1.3
Magnetometer offset cancellation
Offset cancellation is the result of performing a set and reset in the magnetic sensor.
The offset cancellation technique is defined as follows:
Hout
=
H-----n----+-----H-----n---–----1-
2
where Hn and Hn-1 are two consecutive magnetic field measurements, one after a set pulse,
the other after a reset pulse.
Considering a magnetic offset (Hoff), the two magnetic field measurements are:
 Set: Hn = H + Hoff
 Reset: Hn-1 = H – Hoff
The offset is cancelled according to the offset cancellation technique:
Hout
=
H-----n----+-----H-----n---–----1-
2
=
2----H------+-----H----o---f--f---–-----H----o---f--f
2
=
H
In the LSM303AH offset cancellation is enabled by setting bit OFF_CANC = 1 (and bit
OFF_CANC_ONE_SHOT = 1 in single measurement mode) in CFG_REG_B_M (61h).
Offset cancellation is automatically managed by the device in continuous mode.
Offset cancellation has to be managed by the user in single measurement mode averaging
two consecutive measurements Hn and Hn-1.
If offset cancellation is disabled, a set of the magnetic sensor is performed anyway.
The set pulse frequency can be configured by setting the Set_FREQ bit in CFG_REG_B_M
(61h).
Magnetometer interrupt
In LSM303AH magnetometer interrupt signal generation is based on the comparison
between data and a programmable threshold.
To enable the interrupt function, in INT_CTRL_REG_M register (63h) the "IEN" bit must be
set to '1'.
In the LSM303AH the user can select the axis/axes in which the interrupt function can be
enabled. In order to do this, the XIEN, YIEN, and ZIEN bits in INT_CTRL_REG_M (63h)
need be set properly.
The threshold value can be programmed by setting the INT_THS_L_REG_M (65h) and
INT_THS_H_REG_M (66h) registers.
The threshold is expressed in absolute value as a 15-bit unsigned number. The threshold
has the same sensitivity as the magnetic data.
When magnetic data exceeds the positive or the negative threshold, the interrupt signal is
generated and the information about the type of interrupt is stored in the
INT_SOURCE_REG_M (64h) register. In particular, when magnetic data exceeds the
positive threshold the P_TH_S_axis bit is set to '1', while if data exceeds the negative
threshold the N_TH_S_axis bit is set to '1'. If magnetic data lay between the positive and the
negative thresholds, no interrupt signal is released.
DocID027766 Rev 6
23/82
82