high performance ultra low-power 3-axis accelerometer
Introduction
This document provides application information for the low-voltage 3-axis digital output
linear MEMS accelerometer provided in the LGA package.
The LIS331DLH is a high performance ultra low-power 3-axis linear accelerometer, which
belongs to the “nano” family of MEMS accelerometers, with digital I
standard output.
The device features ultra low-power operational modes that allow advanced power saving
and smart Sleep to Wakeup functions.
The LIS331DLH has dynamically user-selectable full scales of ±2 g /±4 g /±8 g and is
capable of measuring acceleration with output data rates from 0.5 Hz to 1 kHz.
The self-test capability allows the user to check the functioning of the sensor in the final
application.
The device can be configured to generate interrupt signals in response to inertial wakeup/free-fall events, or based on the position of the device itself.
The thresholds and timing of interrupt generators are programmable by the end user while
fully operational. The LIS331DLH is available in a small, thin plastic land grid array (LGA)
package, and is guaranteed to operate over a wide temperature range of -40 °C to +85 °C.
Once the device is powered up it automatically downloads the calibration coefficients from
the embedded Flash memory to the internal registers. When the boot procedure is complete
(i.e. after about 5 milliseconds), the device automatically enters power-down mode.
To turn on the device and gather acceleration data, it is necessary to select one of the
operating modes through the CTRL_REG1 register, and to enable at least one of the axes.
The following general-purpose sequence can be used to configure the device:
1.write CTRL_REG1
2. write CTRL_REG2
3. write CTRL_REG3
4. write CTRL_REG4
5. write Reference
6. write INT1_THS
7. write INT1_DUR
8. write INT2_THS
9. write INT2_DUR
10. read HP_FILTER_RESET (if filter is enabled)
11. write INT1_CFG
12. write INT2_CFG
13. write CTRL_REG5
Register values can be changed at any time, and with the device in any operating mode.
Modifications take effect immediately.
Note that in case of changes in full scale, ODR or enabling/disabling of self-test, the output
of the device will require 1 ms + 1/ODR to settle (see Table 11). If the HP filter cut-off
frequency is changed, the filter can be reset by reading the HP_FILTER_RESET register.
Doc ID 15136 Rev 27/31
Start-up sequenceAN2847
2.1 Reading acceleration data
2.1.1 Using the status register
The device features a STATUS_REG register which should be polled to check when a new
set of data is available. The reading procedure is the following:
1read STATUS_REG
2if STATUS_REG(3) = 0 then goto 1
3if STATUS_REG(7) = 1 then some data have been overwritten
4read OUTX_L
5read OUTX_H
6read OUTY_L
7read OUTY_H
8read OUTZ_L
9read OUTZ_H
10data processing
11goto 1
The check performed at step 3 determines whether the reading rate is adequate compared
to the data production rate. In cases where one or more acceleration samples have been
overwritten by new data due to an excessively slow reading rate, the ZYXOR bit of the
STATUS_REG register is set to 1.
The overrun bits are automatically cleared when all the data present inside the device have
been read and new data have not been produced in the meantime.
2.1.2 Using the data-ready signal
The device may be configured to have one HW signal to determine when a new set of
measurement data is available for reading. This signal is represented by the XYZDA bit of
the STATUS_REG register. The signal can be driven to the INT1 or INT2 pins and its polarity
set to active-low or active-high through the CTRL_REG3 register. The interrupt is reset
when the higher part of the data of all the enabled channels has been read.
2.1.3 Using the block data update feature
If the reading of the acceleration data is particularly slow and cannot be (or does not need to
be) synchronized with either the XYZDA bit within the STATUS_REG or with the RDY signal,
it is strongly recommended to set the BDU (block data update) bit in CTRL_REG4 to 1.
This feature prevents the need to read the values (most significant and least significant parts
of the acceleration data) related to different samples. In particular, when the BDU is
activated, the data registers related to each channel always contain the most recent
acceleration data produced by the device. But if the reading of a given pair (i.e. OUTX_H
and OUTX_L, OUTY_H and OUTY_L, OUTZ_H and OUTZ_L) is initiated, the refresh for
that pair is blocked until both the MSB and LSB parts of the data are read.
8/31Doc ID 15136 Rev 2
AN2847Start-up sequence
Note:BDU only guarantees that OUTX(Y, Z)_L and OUTX(X,Z)_H have been sampled at the
same moment. If the reading speed is too low, it is possible, for example, to read X and Y
sampled at T1 and Z sampled at T2.
2.2 Output data rate selection and reading timing
The output data rate is user selectable through the DRx bits of the CTRL_REG1 (20h)
register. At power-on-reset, the DRx are reset to 0, thus providing a default output data rate
of 50 Hz.
The analog signal coming from the mechanical sensor is filtered by a low pass filter before
being converted by the internal ADC. The frequency at -3 dB of the low pass filter
determines the effective system resolution. The cut-off frequency depends on the DR<1:0>
bits in the CTRL_REG1 (20h) register (Table 2).
Table 2.Output data rate
DR1, DR0Output data rate
0050 Hz37 Hz
01100 Hz74 Hz
10400 Hz292 Hz
111000 Hz780 Hz
Analog filter
cut-off frequency (-3 dB)
Note:The output data rate precision is related to the internal oscillator; an error of +/- 10% should
be taken into account.
A typical reading period is defined which is 616 µs shorter than the output data rate period,
in order to prevent the loss of any data produced. During this time period the reading of the
data must be performed and the DataReady signal can be used as a trigger to begin the
reading sequence. At the end of the complete sequence, the DataReady signal goes down
and the rising edge that follows signals that new data are available. If this minimum reading
frequency is not observed, some data loss is possible and the DataReady signal is no
longer considered a trigger signal. The status register can be used to infer the occurrence of
an overrun.
Figure 1.Reading timing
4
44
.EWDATAAVAILABLE
$ATA2EADY
Table 3.Timing value to prevent data loss
TimeDescriptionTyp
T0Data rate1/ODR
Doc ID 15136 Rev 29/31
".W
Start-up sequenceAN2847
Table 3.Timing value to prevent data loss
TimeDescriptionTyp
T1Reading periodT0-T2
T2New data generation616 µs
2.3 Data ready vs. interrupt signal
The device has two pins which can be activated to generate either the data-ready signal or
the interrupt signal. The functionality of the pins is selected acting on bit I1(2)_CFGx bits of
the CTRL_REG3 register, according to Table 4 and the block diagram shown in Figure 2.
Table 4.Data signal on INT 1 and INT 2 pads
I1(2)_CFG1I1(2)_CFG0INT 1(2) Pin
00Interrupt 1 (2) source
01Interrupt 1 source OR Interrupt 2 source
10Data ready
11Boot running
Figure 2.Interrupt and DataReady signal generation block diagram
/$2#LOCK
&REE&ALL
7AKE5P
)NTERRUPT
'ENERATOR
&REE&ALL
7AKE5P
)NTERRUPT
'ENERATOR
)!
).4?32#
/$2#LOCK
)!
).4?32#
#OUNTER
).4X?$52!4 )/.
#OUNTER
).4X?$52!4)/.
,ATCH
#42,?2%',)2
,ATCH
#42,?2%',)2
$ATA2EADY
3IGNAL
'ENERATOR
$ATA2EADYSIGNAL
"//4
TO
).4
0AD
)?#&'
)?#&'
".W
In particular, the data-ready (DR) signal rises to 1 when a new set of acceleration data has
been generated and is available for reading. The signal is reset after all the enabled
channels are read through the serial interface.
10/31Doc ID 15136 Rev 2
AN2847Start-up sequence
Figure 3.Data-ready signal
.ELPMA3LECC!.ELPMA3LECC!!4!$,%##!
2$9
$!4!2%!$
89:89:
".W
2.4 Understanding acceleration data
The measured acceleration data are sent to the OUTX_H, OUTX_L, OUTY_H, OUTY_L,
OUTZ_H and OUTZ_L registers. These registers contain, respectively, the most significant
part and the least significant part of the acceleration signals acting on the X, Y and Z axes.
The complete acceleration data for the X (Y, Z) channel is given by the concatenation
OUTX_H & OUTX_L (OUTY_H & OUTY_L, OUTZ_H & OUTZ_L) and is expressed as a 2’s
complement number.
2.4.1 Data alignment
Acceleration data are represented as 16-bit numbers and are left justified.
2.4.2 Big-little endian selection
The LIS331DLH allows the swapping of the content of the lower and the upper part of the
acceleration registers (i.e. OUTX_H with OUTX_L), to be compliant with both little-endian
and big-endian data representations.
“Little endian” means that the low-order byte of the number is stored in memory at the
lowest address, and the high-order byte at the highest address (the little end comes first).
This mode corresponds to bit BLE in the CTRL_REG4 reset to 0 -default configuration-.
Conversely, “big endian” means that the high-order byte of the number is stored in memory
at the lowest address, and the low-order byte at the highest address.
2.4.3 Example of acceleration data
The following table provides a few basic examples of the data that will be read in the data
registers when the device is subject to a given acceleration. The values listed in the table
are based on the assumption that the device is perfectly calibrated (i.e., no offset, no gain
error, etc.) and show the effect of the BLE bit.
Doc ID 15136 Rev 211/31
Start-up sequenceAN2847
Table 5.Output data register content vs. acceleration (FS = 2 g)
BLE = 0BLE = 1
Acceleration
values
28h29h28h29h
0 g00h00h00h00h
350 mgE0h15h15hE0h
1 g00h40h40h00h
-350 mg20hEAhEAh20h
-1g00hC0HC0H00h
Register address
12/31Doc ID 15136 Rev 2
AN2847Operating modes
3 Operating modes
The LIS331DLH can operate in the following four modes, which can be selected through the
configuration of CTR_REG1 and CTRL_REG5:
●Normal mode
●Power down
●Low power
●Sleep to wake
With reference to the datasheet of the device, the PowerMode (PM) and DataRate (DR) bits
of CTRL_REG1 register are used to select the basic operating modes (Power Down, Normal
mode and Low Power). The TurnOn bits of the CTRL_REG5 register are used to enable
Sleep to Wake, which is an advanced mode involving the interrupt configuration also.
Note:The PMx bits are disabled if the TurnOnx bits of the CTRL_REG5 are not configured as
zeros.
Table 6.Power mode and low-power output data rate configurations
PM2PM1PM0Power mode selection
000Power Down--
001Normal modeODR
010Low Power0.5
011Low Power1
100Low Power2
101Low Power5
110Low Power10
Output data rate [Hz]
ODR
Table 7.CTRL_REG1 - data rate
DR!DR0
0050
01100
10400
111000
Data rate generation [Hz]
ODR
LP
Doc ID 15136 Rev 213/31
Operating modesAN2847
Table 8.CTRL_REG5 - sleep to wake configuration
TurnOn1TurnOn0Sleep to wake status
00Sleep to wake function disabled
01
10Not allowed
11Sleep to wake function enabled
An interrupt event has occurred and the system is generating data at
ODR
Table 9 and Table 10 show the typical power consumption values for the different operating
modes.
Note:Higher data rates correspond to lower device resolution.
Table 9.Power consumption - normal mode (µA)
ODR50 Hz100 Hz400 Hz1000 Hz
Power consumption 250255290370
Table 10.Power consumption - low power mode (µA)
ODR\ODR
100 Hz1015204080
400 Hz1015204080
1000 Hz510153060
LP
50 Hz1020306099
0.5 Hz1 Hz2 Hz5 Hz10 Hz
3.1 Normal mode
In Normal mode, data are generated at the data rate (ODR) selected through the DR bits
and for the axis enabled through the Zen, Yen and Xen bits of the CTRL_REG1 register.
Data generated for a disabled axis is 00h.
Data interrupt generation is active and configured through the INT1_CFG and INT2_CFG
registers.
3.2 Power down mode
When the device is in Power Down mode, almost all internal blocks of the device are
switched off to minimize power consumption. Digital interfaces (I
to allow communication with the device. The content of the configuration register is
preserved and output data registers are not updated, thus keeping in memory the last data
sampled before going to Power Down mode.
2
C and SPI) are still active
Typical turn-on time to return to Normal mode is 1 ms + 1/ODR.
14/31Doc ID 15136 Rev 2
AN2847Operating modes
Table 11.Turn on time
Data rate generation (Hz)Turn on time - TYP (ms)
5021
10011
4003.5
10002
3.3 Low power mode
When the device is in Low Power mode data are produced at the ODRLP selected by the PM
bits of CTRL_REG1.
Turn on time follows the same rules as for power down mode (Table 11).
3.4 Sleep to wake
The sleep to wake function, in conjunction with Low Power mode, allows further reduction of
system power consumption and the development of new smart applications. The
LIS331DLH can be set in a low-power operating mode, characterized by lower date rate
refreshments. In this way the device, even if “sleeping”, continues sensing acceleration and
generating interrupt requests.
When the sleep to wake function is activated, the LIS331DLH is able to automatically wake
up as soon as the interrupt event has been detected, increasing the output data rate and
bandwidth. With this feature the system can be efficiently switched from Low Power mode to
full performance, depending on user-selectable positioning and acceleration events, thus
ensuring power saving and flexibility.
The sleep to wake function is activated through TurnOnx bits of CTRL_REG5 (Table 8).
When the device is in Sleep to Wake mode, it automatically samples the acceleration data at
ODR
to verify if interrupt conditions are reached. When an interrupt event occurs, the
LP
device goes back to generate data at ODR (Figure 4). In case interrupt conditions are not
reached, the device remains in Low Power mode at ODR
LP
.
The device is ready to immediately generate valid samples as soon as it exits from Sleep to
Wake mode.
Note:When an interrupt event occurs, the content of CTR_REG5 changes to 0x01 while the
content of CTRL_REG1 is left untouched. The PMx bits are ignored. To return to Normal
Mode or Low Power mode, the TurnOnx bits of CTRL_REG5 must be set to zero.
Doc ID 15136 Rev 215/31
Operating modesAN2847
Figure 4.Sleep to wake mode
7!+%50
4(2%3(/,$
G
7AKE5P
)NTERRUPT
$2$2$2$2$2$2$2
$2$2$2
/$2
3.4.1 Entering the sleep to wake mode
Perform the following procedure to set up the Sleep to Wake function:
1.Configure the desired interrupt event (Free-fall, Wake-up, 6D position or 6D
movement).
2. Select the desired low power mode (ODR
3. Enable the sleep to wake mode through CTRL_REG5 (TurnOn1 = TurnOn0 = 1).
Once an interrupt event occurs, the TurnOn bits change to TurnOn1 = 0 and TurnOn0 = 1
and the system generates data at ODR. The user can re-activate the Sleep to Wake function
by executing step 3 again.
3.4.2 Exiting the sleep to wake mode
To return to normal mode or to Low Power mode, the user must disable the sleep to wake
function by setting TurnOn1 = TurnOn0 = 0.
/$2
,0
) and Data Rate (ODR) in CTRL_REG1.
LP
".W
16/31Doc ID 15136 Rev 2
AN2847High pass filter
4 High pass filter
The LIS331DLH provides embedded high-pass filtering capability to easily remove the DC
component of the measured acceleration. As shown in Figure 5, it is possible to
independently apply the filter on the output data and/or on the interrupts data through the
FDS, HPen1 and HPen2 bits of the CTRL_REG2 register configuration. This means that it is
possible, for example, to obtain filtered data while interrupt generation works on unfiltered
data.
As shown in Table 12, two operating modes are possible for the high-pass filter:
:
Table 12.High-pass filter mode configuration
#42,?2%'&$3
)NTERRUPT
#42,?2%'(0EN
)NTERRUPT
#42,?2%'(0EN
3OURCE
3OURCE
/UTPUTREGS
32#REG
32#REG
".W
HPM1HPM0
00Normal mode (reset reading HP_RESET_FILTER)
01Reference mode
10Same as configuration 00h
11Not allowed
The bandwidth of the high-pass filter depends on the selected ODR and on the settings of
the HPCFx bits of CTRL_REG2. The high-pass filter cut-off frequencies (f
) are shown in
t
Table 13.
Doc ID 15136 Rev 217/31
High pass filterAN2847
Table 13.High-pass filter cut-off frequency configuration
HPcoeff2,1
0012820
010.51410
100.250.525
110.1250.2512.5
Data rate = 50 Hz
4.1.1 Normal mode
In this configuration the high-pass filter can be reset by reading the HP_FILTER_RESET
register, instantly matching the output data to the input acceleration.
Figure 6.HP_FILTER_RESET readings
ft [Hz]
ft [Hz]
Data rate = 100 Hz
)NPUT!CCELERATION
&ILTERED$ATA
ft [Hz]
Data rate = 400 Hz
ft [Hz]
Data rate = 1000 Hz
4.1.2 Reference mode
In Reference mode configuration the output data is calculated as the difference between the
input acceleration and the content of the REFERENCE register. This register is in 2’s
complement representation and the value of 1LSB of these 7-bit registers depends on the
selected full scale (Table 14).
Table 14.Reference mode LSB value
Full scaleReference mode LSB value (mg)
2~16
4~31
8~63
18/31Doc ID 15136 Rev 2
".W
AN2847High pass filter
Figure 7.Reference mode
)NPUT!CCELERATION
&ILTERED$ATA
2%&%2%.#%
2%&%2%.#%ENABLE
".W
Doc ID 15136 Rev 219/31
Interrupt generationAN2847
5 Interrupt generation
The LIS331DLH can provide two interrupt signals and offers several possibilities for
personalizing these signals. The registers involved in the interrupt generation behavior are
CTRL_REG3, INT1_CFG, INT2_CFG, INT1_THS, INT2_THS, INT1_DURATION, and
INT2_DURATION.
The LIS331DLH interrupt signal can behave as Free-Fall, Wake-Up or 6D orientation
detection.
Table 15.Interrupt mode configuration
AOI6DInterrupt mode
00OR combination of interrupt events
016 direction movement recognition
10AND combination of interrupt events
116 direction position recognition
Whenever an interrupt condition is verified, the interrupt signal is generated and by reading
the INT1_SRC and INT2_SRC registers it is possible to detect which condition has
occurred.
5.1 Duration
The content of the duration registers set the minimum duration of the interrupt event to be
recognized. Duration steps and maximum values depend on the ODR chosen.
When in Normal mode, duration time is measured in N/ODR, where N is the content of the
duration register and ODR is 50, 100, 400, 1000 Hz.
Table 16.Duration LSB value in normal mode
ODR (Hz)Duration LSB value (ms)
When in low power mode, duration time is measured in N/ODR
the duration register and ODR
5020
10010
4002.5
10001
is 0.5, 1, 2, 5, 10 Hz.
LP
, where N is the content of
LP
20/31Doc ID 15136 Rev 2
AN2847Interrupt generation
Table 17.Duration LSB value in low power mode
ODR (Hz)Duration LSB value (s)
0.52
11
20.5
50.2
100.1
5.2 Threshold
Threshold registers define the reference accelerations used by the interrupt generation
circuitry. The value of 1LSB of these 7-bit registers depends on the selected full scale
(Table 18).
Table 18.Threshold LSB value
Full scaleThreshold LSB value (mg)
2~16
4~31
8~63
5.3 Free-fall and wake-up interrupts
The LIS331DLH interrupt signals can behave as free-fall, wake-up or 6D orientation
detection. When an interrupt condition is verified, the interrupt signal is generated and by
reading the INT1_SRC and INT2_SRC registers it is possible to determine which condition
has occurred.
The Free-Fall signal (FF) and Wake-Up signal (WU) interrupt generation block is
represented in Figure 8.
FF or WU interrupt generation is selected through the AOI bit in INTx_CFG register. If the
AOI bit is ‘0’, signals coming from comparators are put in logical “OR”. Depending on the
values written in the INT1_CFG register, every time the value of at least one of the enabled
axes exceeds the threshold written in module in INTx_THS registers, a WU interrupt is
generated. Otherwise, if the AOI bit is ‘1’, signals coming from the comparators go into a
“NAND” port. In this case, an interrupt signal is generated only if all the enabled axes
exceed the threshold written in the INTx_THS register.
The LIRx bits of the CTRL_REG3 can be used to determine whether or not the interrupt
request must be latched. If the LIRx bit is ‘0’ (default value), the interrupt signal goes high
when the interrupt condition is satisfied and immediately returns low if the interrupt condition
is no longer verified. Otherwise, if the LIRx bit is ‘1’, when an interrupt condition is applied,
the interrupt signal remains high even if the condition returns to a non-interrupt status, until
a reading of the INTx_SRC register is performed.
Doc ID 15136 Rev 221/31
Interrupt generationAN2847
The ZHIE, ZLIE, YHIE, YLIE, XHIE and HLIE bits of the INTx_CFG register select on which
axis the interrupt decision must be performed, and in which direction the threshold must be
exceeded to generate the interrupt request.
Figure 8.Free-fall, wake-up interrupt generator
THS reg
Accel_X
Accel_Y
Accel_Z
|b|>a?
|b|<a?
|b|>a?
|b|<a?
|b|>a?
|b|<a?
XHE
XLE
YHE
YLE
ZHE
a
ZLE
WU
0
1
FF
INTx_CFG(AOI)
b
a
0
0
1
1
1
0
INTx_CFG(AOI)
The threshold module which is used by the system to detect free-fall or inertial wake-up
events is defined by the INTx_THS registers. The threshold value is expressed over 7 bits as
an unsigned number and is symmetrical around the zero-g level. XH (YH, ZH) is true when
the unsigned acceleration value of the X (Y, Z) channel is higher than INTx_THS. Similarly,
XL, (YL, ZL) low is true when the unsigned acceleration value of the X (Y, Z) channel is
lower than INTx_THS. Refer to Figure 9 for additional details.
22/31Doc ID 15136 Rev 2
b
AN2847Interrupt generation
Figure 9.FF_WU_CFG high and low
&ULL3CALE
89:HIGH
4HRESHOLDMODULE
0OSITIVE
ACCELERATION
89 :LOW
89:HIGH
GLEVEL
4HRESHOLDMODULE
&ULL3CALE
.EGATIVE
ACCELERATION
!-V
Doc ID 15136 Rev 223/31
Interrupt generationAN2847
5.4 Inertial wake-up
The wake-up interrupt refers to a specific configuration of the INTx_CTRL registers that
allow the interrupt generation when the acceleration on the configured axis exceeds a
defined threshold (Figure 10).
Figure 10. Inertial wake-up interrupt
WAKE UP
WAKE UP
THRESHOLD
0 g
0 g
WU Interrupt
WKP Interrupt
WKP Interrupt
THRESHOLD
5.4.1 HP filter bypassed
This paragraph provides a basic algorithm which shows the practical use of the inertial
wake-up feature. In particular, with the code below, the device is configured to recognize
when the absolute acceleration along either X or Y axis exceeds a preset threshold (250 mg
used in the example). The event which triggers the interrupt is latched inside the device and
its occurrence is signaled through the usage of the INT1 pin.
1write 2Fh into CTRL_REG1
2write 00h into CTRL_REG2// High pass filter disabled
3write 00h into CTRL_REG3// Latched interrupt active high on INT1 pad
4write 00h into CTRL_REG4// FS = 2 g
5write 00h into CTRL_REG5// Sleep to Wake disabled
6write10h into INT1_THS// Threshold = 250 mg
7write 00h into INT1_DURATION// Duration = 0
8write 0Ah into INT1_CFG// Enable XH and YH interrupt generation
9poll INT1 pad; if INT1=0 then goto 8
10read INT1_SRC
// Turn on the sensor and enable X, Y and Z
// ODR = 100 Hz
// Poll RDY/INT pin waiting for the
// wake-up event
// Return the event that has triggered the
// interrupt
11
12goto 8
24/31Doc ID 15136 Rev 2
(Wake-up event has occurred; insert
your code here)
// Event handling
AN2847Interrupt generation
5.4.2 Using the HP filter
The code which follows provides a basic routine showing the practical use of the inertial
wake-up feature performed on high-pass filtered data. In particular, the device is configured
to recognize when the high-frequency component of the acceleration applied along either
the X, Y or Z axis exceeds a preset threshold (250 mg is used in the example). The event
which triggers the interrupt is latched inside the device and its occurrence is signalled
through the INT1 pin.
1write 2Fh into CTRL_REG1
2write 15h into CTRL_REG2// High pass filter enabled on data and interrupt1
3write 00h into CTRL_REG3// Latched interrupt active high on INT1 pad
4write 00h into CTRL_REG4// FS = 2 g
5write 00h into CTRL_REG5// Sleep to Wake disabled
6write10h into INT1_THS// Threshold = 250 mg
7write 00h into INT1_DURATION// Duration = 0
8read HP_FILTER_RESET
9write 2Ah into INT1_CFG// Configure desired wake-up event
10poll INT1 pad; if INT1 = 0 then goto 9
11
12read INT1_SRC
13(Insert your code here)// Event handling
14goto 9
(Wake-up event has occurred; insert
your code here)
// Turn on the sensor, enable X, Y and Z
// ODR = 100 Hz
// Dummy read to force the HP filter to
// actual acceleration value
// (i.e. set reference acceleration/tilt value)
// Poll INT1 pin waiting for the
// wake-up event
// Event handling
// Return the event that has triggered the
// interrupt and clear interrupt
At step 8, a dummy read at the HP_FILTER_RESET register is performed to set the
current/reference acceleration/tilt state against which the device performed the threshold
comparison.
This read may be performed any time it is required to set the orientation/tilt of the device as
a reference state without waiting for the filter to settle.
5.5 Free-fall detection
Free-fall detection refers to a specific configuration of the INTx_CTRL registers that allows
the recognition of device free-fall: the acceleration measurements along all the axes go to
zero. In real cases, a “free-fall zone” is defined around the zero-g level, where all
accelerations are small enough to generate the interrupt (Figure 11).
Doc ID 15136 Rev 225/31
Interrupt generationAN2847
Figure 11. Free-fall interrupt
:
9
G
8
&&)NTERRUPT
&2%%&!,,
:/.%
!-V
This paragraph provides the fundamentals for using the free-fall detection feature. In
particular, the software routine which configures the device to detect and signal free-fall
events is as follows:
1write 2Fh into CTRL_REG1
2write 00h into CTRL_REG2// High pass filter disabled
// Turn on the sensor, enable X, Y and Z
// ODR = 100 Hz
3write 04h into CTRL_REG3// Latched interrupt on INT1
4write 16h into INT1_THS// Set free-fall threshold = 350mg
5write 03h into INT1_DURATION// Set minimum event duration
6write 95h into INT1_CFG// Configure free-fall recognition
7poll INT1 pad; if INT1 = 0 then goto 8// Poll INT1 pin waiting for the free-fall event
8
9read INT1_SRC register// Clear interrupt request
10goto 7
(Free-fall event has occurred; insert your
code here)
The code sample exploits a threshold set at 350 mg for free-fall recognition and the event is
notified by the hardware signal INT1. At step 5, the INT1_DURATION register is configured
to ignore events that are shorter than 3/DR = 3/100 ~= 30 ms in order to avoid false
detections.
Once the free-fall event has occurred, a read at
the device is ready to recognize other events.
5.6 6D direction
The LIS331DLH features an advanced capability to detect the orientation of the device in
space. The 6D direction function can be enabled through the AOI and 6D bits of the
INT1_CFG register (Table 3). When configured for the 6D function, the ZH, ZL, YH, YL, XH,
// Event handling
the INT1_SRC register clears the request and
26/31Doc ID 15136 Rev 2
AN2847Interrupt generation
XL bits of INTx_SRC send information about the value of the acceleration generating the
interrupt when it exceeds the threshold, and whether the acceleration value is positive or
negative. More specifically:
●ZH (YH, XH) is 1 when the sensed acceleration is greater than the threshold in the
positive direction.
●ZL, (YL, XL) is 1 when the sensed acceleration is greater than the threshold in the
negative direction.
Figure 12. ZH, ZL, YH, YL, XH, XLbehavior
&ULL3CALE
8(9(:(
4HRESHOLDMODULE
8(9(:(
GLEVEL
8,9,:,
4HRESHOLDMODULE
8,9,:,
&ULL3CALE
0OSITIVE
ACCELERATION
.EGATIVE
ACCELERATION
!-V
There are two possible configurations for the 6D direction function:
●6D movement recognition: In this configuration the interrupt is generated when the
device moves from one direction (known or unknown) to a different, known direction.
The interrupt is active only for 1/ODR.
●6D position recognition: In this configuration the interrupt is generated when the
device is stable in a known direction. The interrupt is active as long as the position is
maintained, as shown in Figure 13, (a) and (b).
In Figure 13, the 6D Movement line shows the behavior of the interrupt when the device is
configured for 6D Movement recognition on the X and Y axes (INT1_CFG = 0x4Ah), while
the 6D Position line shows the behavior of the interrupt when the device is configured for 6D
Position recognition on the X and Y axes (INT1_CFG = 0xCAh). INT1_THS is set to 0x21.
With reference to Figure 14, the device has been configured for the 6D Position function on
the X, Y and Z axes. Table 19 shows the content of the INT1_SRC register for each
position.
Doc ID 15136 Rev 227/31
Interrupt generationAN2847
Figure 13. 6D movement vs. 6D position
$-OVEMENT
$0OSITION
8
9
A
:
Figure 14. 6D recognized positions
:
B
!-V
:
:
9
9
8
8
:
:
9
9
8
8
BA
:
:
9
9
:
:
9
9
8
9
:
:
4OP
4OP
28/31Doc ID 15136 Rev 2
8
8
8
8
DC
:
9
9
"OTTOM
8
8
9
8
FE
!-V
AN2847Interrupt generation
Table 19.INTx_SRC register in 6D position
CaseIAZHZLYHYLXHXL
(a)1000100
(b)1000010
(c)1000001
(d)1001000
(e)1100000
(f)1010000
Doc ID 15136 Rev 229/31
Revision historyAN2847
6 Revision history
Table 20.Document revision history
DateRevisionChanges
26-Jan-20091Initial release.
08-Sep-20102
Updated Table 5: Output data register content vs. acceleration (FS =
2 g).
30/31Doc ID 15136 Rev 2
AN2847
Please Read Carefully:
Information in this document is provided solely in connection with ST products. STMicroelectronics NV and its subsidiaries (“ST”) reserve the
right to make changes, corrections, modifications or improvements, to this document, and the products and services described herein at any
time, without notice.
All ST products are sold pursuant to ST’s terms and conditions of sale.
Purchasers are solely responsible for the choice, selection and use of the ST products and services described herein, and ST assumes no
liability whatsoever relating to the choice, selection or use of the ST products and services described herein.
No license, express or implied, by estoppel or otherwise, to any intellectual property rights is granted under this document. If any part of this
document refers to any third party products or services it shall not be deemed a license grant by ST for the use of such third party products
or services, or any intellectual property contained therein or considered as a warranty covering the use in any manner whatsoever of such
third party products or services or any intellectual property contained therein.
UNLESS OTHERWISE SET FORTH IN ST’S TERMS AND CONDITIONS OF SALE ST DISCLAIMS ANY EXPRESS OR IMPLIED
WARRANTY WITH RESPECT TO THE USE AND/OR SALE OF ST PRODUCTS INCLUDING WITHOUT LIMITATION IMPLIED
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE (AND THEIR EQUIVALENTS UNDER THE LAWS
OF ANY JURISDICTION), OR INFRINGEMENT OF ANY PATENT, COPYRIGHT OR OTHER INTELLECTUAL PROPERTY RIGHT.
UNLESS EXPRESSLY APPROVED IN WRITING BY AN AUTHORIZED ST REPRESENTATIVE, ST PRODUCTS ARE NOT
RECOMMENDED, AUTHORIZED OR WARRANTED FOR USE IN MILITARY, AIR CRAFT, SPACE, LIFE SAVING, OR LIFE SUSTAINING
APPLICATIONS, NOR IN PRODUCTS OR SYSTEMS WHERE FAILURE OR MALFUNCTION MAY RESULT IN PERSONAL INJURY,
DEATH, OR SEVERE PROPERTY OR ENVIRONMENTAL DAMAGE. ST PRODUCTS WHICH ARE NOT SPECIFIED AS "AUTOMOTIVE
GRADE" MAY ONLY BE USED IN AUTOMOTIVE APPLICATIONS AT USER’S OWN RISK.
Resale of ST products with provisions different from the statements and/or technical features set forth in this document shall immediately void
any warranty granted by ST for the ST product or service described herein and shall not create or extend in any manner whatsoever, any
liability of ST.
ST and the ST logo are trademarks or registered trademarks of ST in various countries.
Information in this document supersedes and replaces all information previously supplied.
The ST logo is a registered trademark of STMicroelectronics. All other names are the property of their respective owners.