English
Language : 

AN4506 Datasheet, PDF (31/47 Pages) STMicroelectronics – This document is intended to provide information
AN4506
Interrupt generation
This paragraph provides the basics for the use of the selective axis movement detection
feature. Here below is reported the example code which implements the SW routine for the
selective axis movement recognition:
1 Write 0Fh into CTRL1
3 Write 80h into CTRL3
4 Write 00h into CTRL4
6 Write 1Fh into IG_THS_XH
7 Write 58h into IG_THS_XL
8 Write 1Fh into IG_THS_YH
9 Write 58h into IG_THS_YL
10 Write 1Fh into IG_THS_ZH
11 Write 58h into IG_THS_ZL
12 Write 01h into IG_DURATION
13 Write 65h into IG_CFG
14 Poll INT1 pad; if INT1=0 then go to 8
15 Read IG_SRC
16
(Wake-up event has occurred; insert
your code here)
17 Go to 15
// Turn on the sensor and enable X, Y, and Z
// ODR = 100 Hz
// Interrupt driven to INT1 pad
// FS = 245 dps
// Threshold = 60 dps
// Threshold = 60 dps
// Threshold = 60 dps
// Threshold = 60 dps
// Threshold = 60 dps
// Threshold = 60 dps
// Duration = 10 ms
// Enable XL, YL and ZH interrupt generation in AND
// configuration. Interrupt latched
// Poll INT1 pin waiting for the
// wake-up event
// Return the event that has triggered the
// interrupt
// Event handling
The code sample exploits a threshold set at 60 dps selective axis movement detection and
the event is notified by the hardware signal INT1. At step 7, the IG_DURATION register is
configured like this to ignore events that are shorter than 1/DR = 1/100 ~= 10 msec in order
to avoid false detections. Once the selective axis movement detection has occurred, a read
of the IG_SRC register clears the request and the device is ready to recognize other events.
DocID026442 Rev 2
31/47