LIS2DH12 ApplicationNode
LIS2DH12 ApplicationNode
Application note
LIS2DH12: MEMS digital output motion sensor
ultra-low-power high-performance 3-axis "nano" accelerometer
Introduction
This document describes the low-voltage 3-axis digital output linear MEMS accelerometer provided in
an LGA package.
The LIS2DH12 is an ultra-low-power high-performance 3-axis linear accelerometer belonging to the
“nano” family, with a digital I2C/SPI serial interface standard output.
The device features ultra-low-power operational modes that allow advanced power saving and smart
sleep-to-wake-up and return-to-sleep functions.
The LIS2DH12 has dynamic user-selectable full scales of ±2g/±4g/±8g/±16g and is capable of
measuring accelerations with output data rates from 1 Hz to 5 kHz.
The device may be configured to generate interrupt signals using an independent inertial wake-up/free-
fall event as well as by the position of the device itself. Thresholds and timing of the interrupt generator
are programmable by the end user on the fly.
Automatic programmable sleep-to-wakeup and return-to-sleep functions are also available for enhanced
power saving.
The LIS2DH12 has an integrated 32-level first-in first-out (FIFO) buffer allowing the user to store data in
order to limit intervention by the host processor.
The LIS2DH12 is available in a small thin plastic land grid array package (LGA) and is guaranteed to
operate over an extended temperature range from -40 °C to +85 °C.
The ultra-small size and weight of the SMD package make it an ideal choice for handheld portable
applications such as smartphones, IoT connected devices, and wearables, or any other application
where reduced package size and weight are required.
List of tables
Table 1: Internal pin status ......................................................................................................................... 6
Table 2: Registers ....................................................................................................................................... 7
Table 3: Operating mode selection ............................................................................................................. 9
Table 4: Data rate configuration ................................................................................................................. 9
Table 5: Current consumption of operating modes .................................................................................. 10
Table 6: Turn-on time for operating mode transition ................................................................................ 12
Table 7: STATUS_REG ............................................................................................................................ 14
Table 8: STATUS_REG description ......................................................................................................... 14
Table 9: Output data registers content vs. acceleration (FS = ±2 g, high-resolution mode) .................... 17
Table 10: High-pass filter mode configuration .......................................................................................... 18
Table 11: Low-power mode - high-pass filter cutoff frequency [Hz] ......................................................... 18
Table 12: Reference mode LSB value ...................................................................................................... 19
Table 13: CTRL_REG3 register ................................................................................................................ 20
Table 14: CTRL_REG3 description .......................................................................................................... 20
Table 15: CTRL_REG6 register ................................................................................................................ 21
Table 16: CTRL_REG6 description .......................................................................................................... 21
Table 17: Interrupt mode configuration ..................................................................................................... 22
Table 18: Duration LSB value in normal mode ......................................................................................... 22
Table 19: INT1_SRC register in 6D positions ........................................................................................... 30
Table 20: CLICK_CFG register ................................................................................................................. 34
Table 21: CLICK_CFG description ........................................................................................................... 34
Table 22: Truth table ................................................................................................................................. 34
Table 23: CLICK_SRC register ................................................................................................................. 35
Table 24: CLICK_SRC description ........................................................................................................... 35
Table 25: CLICK_THS register ................................................................................................................. 35
Table 26: CLICK_THS description............................................................................................................ 35
Table 27: TIME_LIMIT register ................................................................................................................. 36
Table 28: TIME_LIMIT register description............................................................................................... 36
Table 29: TIME_LATENCY register .......................................................................................................... 36
Table 30: TIME_LATENCY description .................................................................................................... 36
Table 31: TIME_WINDOW description ..................................................................................................... 36
Table 32: TIME_WINDOW description ..................................................................................................... 36
Table 33: CTRL_REG3 register ................................................................................................................ 37
Table 34: CTRL_REG3 description .......................................................................................................... 37
Table 35: FIFO buffer full representation (32nd sample set stored) ......................................................... 41
Table 36: FIFO overrun representation (33rd sample set stored and 1st sample discarded) .................. 42
Table 37: FIFO enable bit in CTRL_REG5 ............................................................................................... 43
Table 38: FIFO_CTRL_REG .................................................................................................................... 44
Table 39: FIFO_SRC_REG ...................................................................................................................... 44
Table 40: FIFO_SRC_REG behavior assuming FTH[4:0] = 15 ................................................................ 45
Table 41: CTRL_REG3 (0x22) ................................................................................................................. 45
Table 42: Revision history ........................................................................................................................ 58
List of figures
Figure 1: Pin connections ........................................................................................................................... 6
Figure 2: DRDY signal synchronization .................................................................................................... 15
Figure 3: Data-ready signal ...................................................................................................................... 15
Figure 4: High-pass filter connections block diagram ............................................................................... 17
Figure 5: Reading REFERENCE .............................................................................................................. 18
Figure 6: Reference mode ........................................................................................................................ 19
Figure 7: Autoreset ................................................................................................................................... 19
Figure 8: Free-fall, wake-up interrupt generator ....................................................................................... 23
Figure 9: FF_WU_CFG high and low ....................................................................................................... 24
Figure 10: Inertial wake-up interrupt ......................................................................................................... 24
Figure 11: Free-fall interrupt ..................................................................................................................... 26
Figure 12: ZH, ZL, YH, YL, XH, and XL behavior ..................................................................................... 28
Figure 13: 6D movement vs. 6D position.................................................................................................. 29
Figure 14: 6D recognized positions .......................................................................................................... 29
Figure 15: Single-click event with non-latched interrupt ........................................................................... 31
Figure 16: Single and double-click recognition ......................................................................................... 32
Figure 17: Double-click recognition .......................................................................................................... 33
Figure 18: Short time limit ......................................................................................................................... 38
Figure 19: Long time limit ......................................................................................................................... 38
Figure 20: Short latency ............................................................................................................................ 39
Figure 21: Long latency ............................................................................................................................ 39
Figure 22: Short window ........................................................................................................................... 40
Figure 23: Long window ............................................................................................................................ 40
Figure 24: FIFO_EN connection block diagram ....................................................................................... 43
Figure 25: FIFO mode behavior ................................................................................................................ 47
Figure 26: Stream mode fast reading behavior ........................................................................................ 48
Figure 27: Stream mode slow reading behavior ....................................................................................... 48
Figure 28: Stream mode slow reading zoom ............................................................................................ 49
Figure 29: Stream-to-FIFO mode: interrupt not latched ........................................................................... 50
Figure 30: Stream-to-FIFO mode: interrupt latched ................................................................................. 50
Figure 31: Watermark behavior - FTH[4:0] = 10 ....................................................................................... 51
Figure 32: FIFO reading diagram - FTH[4:0] = 10 .................................................................................... 52
Figure 33: Activity / Inactivity recognition.................................................................................................. 53
Figure 34: Activity / Inactivity duration ...................................................................................................... 54
Figure 35: Self-test procedure .................................................................................................................. 57
1 Pin description
Figure 1: Pin connections
INT 2
INT 1
Z
11 12
Vdd_IO 10 12 14 1 SCL/SPC
Vdd 11 1 CS
1
GND SDO/SA0
8 4
GND 7 4 SDA/SDI/SDO
6 5
RES
GND
X Y
(TOP VIEW) (BOTTOM VIEW)
DIRECTION OF THE
DETECTABLE
ACCELERATIONS
Notes:
(1)In order to disable the internal pull-up on the SDO/SA0 pin, write 90h in CTRL_REG0 (1Eh).
2 Registers
Table 2: Registers
Register name Address Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
STATUS_REG_AUX 07h - TOR - - - TDA - -
RESERVED 08h -0Bh
OUT_TEMP_L 0Ch Temp7 Temp6 Temp5 Temp4 Temp3 Temp2 Temp1 Temp0
OUT_TEMP_H 0Dh Temp15 Temp14 Temp13 Temp12 Temp11 Temp10 Temp9 Temp8
RESERVED 0Eh
WHO_AM_I 0Fh 0 0 1 1 0 0 1 1
SDO_PU_
CTRL_REG0 1Eh 0(1) 0(1) 1(2) 0(1) 0(1) 0(1) 0(1)
DISC
TEMP_CFG_REG 1Fh TEMP_EN1 TEMP_EN2 0 0 0 0 0 0
CTRL_REG1 20h ODR3 ODR2 ODR1 ODR0 LPen Zen Yen Xen
CTRL_REG2 21h HPM1 HPM0 HPCF2 HPCF1 FDS HPCLICK HP_IA2 HP_IA1
I1_
CTRL_REG3 22h I1_CLICK I1_IA1 I1_IA2 I1_ZYXDA 0(1) I1_WTM -
OVERRUN
CTRL_REG4 23h BDU BLE FS1 FS0 HR ST1 ST0 SIM
CTRL_REG5 24h BOOT FIFO_EN - - LIR_INT1 D4D_INT1 LIR_INT2 D4D_INT2
INT_
CTRL_REG6 25h I2_CLICK I2_IA1 I2_IA2 I2_BOOT I2_ACT - -
POLARITY
REFERENCE 26h REF7 REF6 REF5 REF4 REF3 REF2 REF1 REF0
STATUS_REG 27h ZYXOR ZOR YOR XOR ZYXDA ZDA YDA XDA
OUT_X_L 28h XD7 XD6 XD5 XD4 XD3 XD2 XD1 XD0
OUT_X_H 29h XD15 XD14 XD13 XD12 XD11 XD10 XD9 XD8
OUT_Y_L 2Ah YD7 YD6 YD5 YD4 YD3 YD2 YD1 YD0
OUT_Y_H 2Bh YD15 YD14 YD13 YD12 YD11 YD10 YD9 YD8
Notes:
(1)This bit must be set to 0 for correct operation of the device.
(2)This bit must be set to 1 for correct operation of the device.
3 Operating modes
The LIS2DH12 provides four different operating modes: power-down mode, high-
resolution/normal mode, and low-power mode. While normal mode guarantees higher
resolution, low-power mode further reduces the current consumption.
After the power supply is applied, the LIS2DH12 performs a 5 ms boot procedure to load
the trimming parameter. After the boot is completed, the device is automatically configured
in power-down mode.
Referring to the LIS2DH12 datasheet, the output data rate (ODR) and the low-power
enable (LPen) bits of CTRL_REG1 and the HR bits of CTRL_REG4 are used to select the
operating modes (power-down mode, high-resolution/normal mode and low-power mode)
and output data rate (Table 3: "Operating mode selection" and Table 4: "Data rate
configuration").
Table 3: Operating mode selection
CTRL_REG1[3] CTRL_REG4[3] BW Turn-on time So @ ±2g
Operating mode
(LPen bit) (HR bit) [Hz] [ms] [mg/digit]
Low-power mode
1 0 ODR/2 1 16
(8-bit data output)
Normal mode
0 0 ODR/2 1.6 4
(10-bit data output)
High-resolution
mode 0 1 ODR/9 7/ODR 1
(12-bit data output)
Not allowed 1 1 -- -- --
4 Startup sequence
Once the device is powered up, it automatically downloads the calibration coefficients from
the embedded flash to the internal registers. When the boot procedure is completed, i.e.
after approximately 5 milliseconds, the device automatically enters power-down mode. To
turn on the device and gather acceleration data, select the HR bit in CTRL_REG4 and the
LPen bit in CTRL_REG1, enable at least one of the axes and select the preferred ODR.
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 CTRL_REG5
6. Write CTRL_REG6
7. Write REFERENCE
8. Write INTx_THS
9. Write INTx_DUR
10. Write INTx_CFG
11. Write CTRL_REG5
The device is provided with a STATUS_REG which should be polled to check when a new
set of data is available. The reading procedure should be the following:
1. Read STATUS_REG
2. If STATUS_REG(3) = 0, then go to 1
3. If STATUS_REG(7) = 1, then some data have been overwritten
4. Read OUTX_L
5. Read OUTX_H
6. Read OUTY_L
7. Read OUTY_H
8. Read OUTZ_L
9. Read OUTZ_H
10. Data processing
11. Go to 1
The check performed at step 3 allows understanding whether the reading rate is adequate
compared to the data production rate. If one or more acceleration samples have been
overwritten by new data, because of an insufficient reading rate, the ZYXOR bit of
STATUS_REG 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.
In order to be sure to have the first DRDY rising edge synchronous with the selected ODR
(avoid condition in Figure 2: "DRDY signal synchronization") set the I1_ ZYXDA bit to ‘1’
before enabling the ODR.
The DRDY signal can change its polarity set to active-low or active-high through
INT_POLARITY of CTRL_REG6. The data-ready signal rises to '1' when a new set of
acceleration data has been generated and is available to be read. DRDY is reset when the
higher part of the data of all the enabled channels has been read (29h, 2Bh, 2Dh).
Note: The LIR_INT1 bits of CTRL_REG5 do not act on the DRDY signal.
Figure 3: Data-ready signal
DRDY
DATA READ
X Y Z X Y Z
ADC 0
Outputregs
1
CTRL_REG2(FDS)
HP Filter
0
Interrupt
Source SRC reg 1
1
CTRL_REG2(HP_IAx)
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 cutoff frequencies (ft) are shown in
Table 11: "Low-power mode - high-pass filter cutoff frequency [Hz]".
Table 11: Low-power mode - high-pass filter cutoff frequency [Hz]
ft [Hz] ft [Hz] ft [Hz] ft [Hz] ft [Hz] ft [Hz] ft [Hz] ft [Hz] ft [Hz]
HPCF[2:1]
@1 Hz @10 Hz @25 Hz @50 Hz @100 Hz @200 Hz @400 Hz @1.6 kHz @5 kHz
00 0.02 0.2 0.5 1 2 4 8 32 100
01 0.008 0.08 0.2 0.5 1 2 4 16 50
10 0.004 0.04 0.1 0.2 0.5 1 2 8 25
11 0.002 0.02 0.05 0.1 0.2 0.5 1 4 12
REFERENCE
Input Acceleration
Filtered Data
REFERENCE
REFERENCE enable
4.3.1.3 Autoreset
In this configuration the filter is automatically reset when the configured interrupt event
occurs. REFERENCE (26h) is, however, used to set the filter instantaneously.
Note: The XYZ dataset used to reset the filter is the one after the interrupt.
Figure 7: Autoreset
Input Acceleration
Filtered Data
REFERENCE enable
5 Interrupt generation
The LIS2DH12 interrupts signals can behave as free-fall, wake-up, 6D and 4D orientation
detection, and click detection. These signals can be driven to the two interrupt pins (INT1
and INT2).
Notes:
(1)This bit must be set to '0' for correct operation of the device.
6 Inertial interrupt
The LIS2DH12 can provide two inertial interrupt signals and offers several possibilities to
personalize these signals. The registers involved in the interrupt generation behavior are
INTx_CFG, INTx_THS and INTx_DURATION.
Table 17: Interrupt mode configuration
AOI 6D Interrupt mode
0 0 OR combination of interrupt events
0 1 6-direction movement recognition
1 0 AND combination of interrupt events
1 1 6-direction position recognition
Whenever an interrupt condition is verified, the interrupt signal is generated and by reading
the INTx_SRC register, it is possible to understand which condition happened.
6.1 Duration
The content of the duration registers sets the minimum duration of the interrupt event to be
recognized. Duration steps and maximum values depend on the ODR chosen.
Duration time is measured in N/ODR, where N is the content of the duration register.
Table 18: Duration LSB value in normal mode
ODR (Hz) Duration LSB value (ms)
1 1000
10 100
25 40
50 20
100 10
200 5
400 2.5
1600 0.6
1344 0.744
5376 0.186
6.2 Threshold
Threshold registers define the reference accelerations used by the interrupt generation
circuitry. The value of 1 LSB of these 7-bit registers depends on the selected full scale and
power mode (refer to “Table 4: Mechanical characteristics” of the LIS2DH12 datasheet).
THS reg
|b|>a?
Accel_X
XHIE
|b|<a?
WU
XLIE
|b|>a?
Accel_Y
0
YHIE
|b|<a? 1
YLIE
|b|>a? FF
Accel_Z
ZHIE
|b|<a? INTx_CFG(AOI)
ZLIE
The threshold module which is used by the system to detect any free-fall or inertial wake-
up event is defined by the INTx_THS register. 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)
+ Full Scale
X (Y, Z) high Positive
Threshold module
acceleration
WAKE UP
0g THRESHOLD
WKP Interrupt
0g FREE FALL
ZONE
X
FF Interrupt
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 7, the INT1_DURATION register is
configured like this to ignore events that are shorter than 3/DR = 3/100 ~= 30 msec in order
to avoid false detections.
Once the free-fall event has occurred, a read of the INT1_SRC register clears the request
and the device is ready to recognize other events.
+ Full Scale
XH (YH, ZH) = 1 Positive
+Threshold
acceleration
XH (YH, ZH) = 0
0 g level
XL (YL, ZL) = 0
-Threshold Negative
XL (YL, ZL) = 1 acceleration
- Full Scale
Z Z
Y Y
X X
( a) ( b)
Z Z Z
Y Y
1
X
X X
Y (c) (d)
Z Z
Y Y
Top Bottom
X X
( e) (f)
In Figure 15: "Single-click event with non-latched interrupt"(a) the click has been
recognized, while in Figure 15: "Single-click event with non-latched interrupt"(b) the click
has not been recognized because the acceleration goes under the threshold after the
TIME_LIMIT has expired.
Figure 16: "Single and double-click recognition" illustrates a single-click event (a) and a
double-click event (b). The device is able to distinguish between (a) and (b) by changing
the settings of the CLICK_CFG register from single to double-click recognition.
In Figure 17: "Double-click recognition"(a) the double-click event has been correctly
recognized, while in Figure 17: "Double-click recognition"(b) the interrupt has not been
generated because the input acceleration exceeds the threshold after the window interval
has expired.
1 LSB = 1/ODR.
TLI7 through TLI0 define the maximum time interval that can elapse between the start of
the click-detection procedure (the acceleration on the selected channel exceeds the
programmed threshold) and when the acceleration falls back below the threshold.
1 LSB = 1/ODR.
TLA7 through TLA0 define the time interval that starts after the first click detection where
the click-detection procedure is disabled, in cases where the device is configured for
double-click detection.
1 LSB = 1/ODR.
TW7 throughTW0 define the maximum interval of time that can elapse after the end of the
latency interval in which the click-detection procedure can start, in cases where the device
is configured for double-click detection.
Notes:
(1)This bit must be set to ‘0’ for correct operation of the device.
8.4 Examples
The following figures show the click interrupt generation in different conditions. The
screenshots have been captured on a PC running the demonstration kit GUI interface with
ODR set to 400 Hz and full scale to 4 g. The content of the LIS2DH12 registers have been
modified via the dedicated panel of the software interface that allows the user to evaluate
all the different settings and features of the click embedded function. In the following
examples, only the X-axis has been enabled for the click interrupt generation.
Table 35: "FIFO buffer full representation (32nd sample set stored)" represents the FIFO
full status when 32 samples are stored in the buffer while Table 36: "FIFO overrun
representation (33rd sample set stored and 1st sample discarded)" represents the next
step when the 33rd sample is inserted into FIFO and the 1st sample is overwritten. The new
oldest sample set is made available in the output registers.
When FIFO is enabled and the mode is different from Bypass, the LIS2DH12 output
registers (28h to 2Dh) always contain the oldest FIFO sample set.
Measurement
ADC
Chain
0
Output Registers
1
FIFO
Buffer
CTRL_REG5 (FIFO_EN)
The FM[1:0] bits define the selection of the behavior of the FIFO buffer:
1. FM[1:0] = (0,0): Bypass mode
2. FM[1:0] = (0,1): FIFO mode
3. FM[1:0] = (1,0): Stream mode
4. FM[1:0] = (1,1): Stream-to-FIFO mode
The trigger used to activate Stream-to-FIFO mode is related to the IA bit value of the
selected INT1_SRC register and does not depend on the interrupt pin value and polarity.
The trigger is generated also if the selected interrupt is not driven to an interrupt pin.
FTH[4:0] bits define the watermark level; when FIFO content exceeds this value the WTM
bit is set to “1” in the FIFO source register.
• WTM bit is set high when FIFO content exceeds watermark level.
• OVRN_FIFO bit is set high when the FIFO buffer is full, which means that the FIFO
buffer contains 32 unread samples. At the following ODR a new sample set replaces
the oldest FIFO value. The OVRN_FIFO bit is reset when the first sample set has
been read.
• EMPTY flag is set high when all FIFO samples have been read and the FIFO is
empty.
• FSS[4:0] field always contains the current number of unread samples stored in the
FIFO buffer. When FIFO is enabled, this value increases at ODR frequency until the
buffer is full, whereas it decreases every time that one sample set is retrieved from
FIFO.
The watermark flag and FIFO overrun event can be enabled to generate a dedicated
interrupt on the INT1 pin by configuring CTRL_REG3.
Table 41: CTRL_REG3 (0x22)
b7 b6 b5 b4 b3 b2 b1 b0
I1_OVER
X X X X X I1_WTM X
RUN
F0 F1 F2 F3 F4 F5 … …F31 … F0 F0 F0 F1 …
0 1 2 3 4 5 … … 31 … 32 33 …
FIFO Reading
OVRN_FIFO
t
FIFO mode FIFO Start FIFO FIFO FIFO Mode
enable s
stop Reading Bypass enable
If FIFO mode is enabled, the buffer starts to collect data and fill all the 32 slots (from F0 to
F31) at the selected output data rate. When the buffer is full, the OVRN_FIFO bit goes high
and data collection is permanently stopped; the user can decide to read FIFO content at
any time because it is maintained unchanged until Bypass mode is selected. The reading
procedure is composed of a set of 32 samples of 6 bytes for a total of 192 bytes and
retrieves data starting from the oldest sample stored in FIFO (F0). The OVRN_FIFO bit is
reset when the first sample set has been read. Setting to Bypass mode resets FIFO and
allows the user to enable FIFO mode again.
F0 F1 F2 F3 F4 F5 … …F31 F0 F1 …F31 F0 F1 … …
0 1 2 3 4 5 … … 31 32 33 … 63 64 65 … …
FIFO Reading
OVRN_FIFO
t
Stream Start FIFO Start FIFO
enable Reading Reading
In Stream mode, the FIFO buffer is continuously filling (from F0 to F31) at the selected
output data rate. When the buffer is full, the OVRN_FIFO flag goes high and the
recommended solution is to read all FIFO samples (192 bytes) faster then 1*ODR, in order
to free FIFO slots for the new acceleration samples. This allows avoiding loss of data and
limiting intervention by the host processor in order to increase efficiency of the system. If
the reading procedure is not fast enough, three different cases can be observed:
1. FIFO sample set (6 bytes) reading faster than 1*ODR: data are correctly retrieved
because a free slot is made available before new data is generated.
2. FIFO sample set (6 bytes) reading synchronous to 1*ODR: data are correctly retrieved
because a free slot is made available before new data is generated but FIFO benefits
are not exploited. This case is equivalent to reading data on data-ready interrupt and
does not limit intervention of the host processor compared to the standard
accelerometer reading.
3. FIFO sample set (6 bytes) reading slower than 1*ODR: in this case some data is lost
because data recovery is not fast enough to free slots for new acceleration data
Figure 27: "Stream mode slow reading behavior". The number of correctly recovered
samples is related to the difference between the current ODR and the FIFO sample
set reading rate.
Figure 27: Stream mode slow reading behavior
FIFO Reading
OVRN_FIFO
t
Stream Start FIFO Start FIFO Samples
enable Reading Reading overwritten
F0 F1 F2 F3 F4 … F31 F0 F1 F2 F3 F4 … …
0 1 2 3 4 … 31 32 33 34 35 36 … …
t0
t
t0+dt t0+31dt
FIFO Reading
R0:0 R1:1 R2:2 R3:35 R4:36
OVRN_FIFO
Stream Start FIFO Samples
enable Reading overwritten
After enabling Stream mode, FIFO slots are filled at the end of each ODR time frame. The
reading procedure must start as soon as the OVRN flag is set to “1”, data are retrieved
from FIFO at the beginning of the read. When a read command is sent to the device, the
content of the output registers is moved to the SPI/I2C register and the current oldest FIFO
value is shifted into the output registers in order to allow the next read. In the case of a
read slower than 1*ODR, some data can be retrieved from FIFO after that new sample is
inserted into the addressed location. In Figure 28: "Stream mode slow reading zoom" the
fourth read command starts after the refresh of the F3 index and this generates a
disconnect in the reading data. The OVRN flag advises the user that this event has taken
place. In this example, three correct samples have been read, the number of correctly
recovered samples is dependent on the difference between the current ODR and the FIFO
sample set reading timeframe.
F0 F1 F32
0 1 2 3 4 5 … … 31 32 33 34 35
FIFO Reading
OVRN_FIFO
t
Stream to FIFO Interrupt lost FIFO Start FIFO
enable stop Reading
F0 F1 F2 F3 F4 F5 F31 F0 F0 F0
0 1 2 3 4 5 … … 31 32
FIFO Reading
OVRN_FIFO
Stream-to-FIFO can be used in order to analyze the sample history that generated an
interrupt; the standard operation is to read FIFO content when FIFO mode is triggered and
the FIFO buffer is full and stopped.
31+
1 2 3 4 5 6 … … 11 12 .. … 31 OVRN 1
F0 F1 F2 F3 F4 F5 … … F10 F11 … …F30 F31 F0
0 1 2 3 4 5 … … 10 11 … … 30 31 32
FIFO Reading
WTM
OVRN_FIFO
t
FIFO Start FIFO
enable Reading
In Figure 31: "Watermark behavior - FTH[4:0] = 10", the first row indicates the FSS[4:0]
value, the second row indicates the relative FIFO slot and last row shows the incremental
FIFO data. Assuming FTH[4:0] = 10, the WTM flag changes from “0” to “1” when the
eleventh FIFO slot is filled (F10). Figure 32: "FIFO reading diagram - FTH[4:0] = 10" shows
that the WTM flag goes low when the FIFO content is less than FTH[4:0], it means that
nine unread sample sets remain in FIFO.
The watermark flag (WTM) can be enabled to generate a dedicated interrupt on the INT1
pin by setting the I1_WTM bit high in CTRL_REG3.
WTM
OVRN_FIFO
EMPTY
t
FIFO Start FIFO FIFO Empty
enable Reading
In Figure 32: "FIFO reading diagram - FTH[4:0] = 10" “Rx” indicates a 6-byte read and “F0*”
represents a single ODR slot expanded for better visibility.
Note: In order to set the EMPTY bit to '1', an additional sample (oldest one repeated) must
be read and discarded.
The user can also route the status (activity/inactivity) of the system to the INT2 pin by
setting to 1 bit I2_ACT in CTRL_REG6. With this feature INT2 is high when the system is in
inactivity ( ODR at 10 Hz ) and goes low when the system is in Activity (user ODR). The
INT_POLARITY bit controls the polarity of the Activity / Inactivity signal.
11 Temperature sensor
In order to enable the internal temperature sensor, bits TEMP_EN[1:0] in register
TEMP_CFG_REG (1Fh) and the BDU bit in CTRL_REG4 (23h) have to be set.
The temperature is available in OUT_TEMP_L (0Ch), OUT_TEMP_H (0Dh) stored as two’s
complement data, left-justified.
The temperature data format can be 10 bits if LPen (bit 3) in CTRL_REG1 (20h) is cleared
(high-resolution / normal mode), otherwise, in low-power mode, the ADC resolution is 8-bit.
Refer to the LIS2DH12 datasheet for the conversion factor.
Read OUT_Z_L (2Ch), OUT_Z_H (2Dh): Store data in OUTZ_NOST |Min(ST_Y)<=|OUTY_ST-OUTY_NOST| <= |Max(ST_Y)|
13 Revision history
Table 42: Revision history
Date Version Changes
10-Feb-2017 1 Initial release
Updated Section 3.4: "High-resolution mode" and Section 8: "Click
and double-click recognition"
08-Jun-2017 2 Updated Table 9: "Output data registers content vs. acceleration
(FS = ±2 g, high-resolution mode)" and Table 22: "Truth table"
Added Section 12: "Accelerometer self-test procedure"
STMicroelectronics NV and its subsidiaries (“ST”) reserve the right to make changes, corrections, enhancements, modifications, and
improvements to ST products and/or to this document at any time without notice. Purchasers should obtain the latest relevant information on ST
products before placing orders. ST products are sold pursuant to ST’s terms and conditions of sale in place at the time of order
acknowledgement.
Purchasers are solely responsible for the choice, selection, and use of ST products and ST assumes no liability for application assistance or the
design of Purchasers’ products.
Resale of ST products with provisions different from the information set forth herein shall void any warranty granted by ST for such product.
ST and the ST logo are trademarks of ST. All other product or service names are the property of their respective owners.
Information in this document supersedes and replaces information previously supplied in any prior versions of this document.