2013-08-29 03:22 PM
I am trying to interface LIS3DH Accelerometer over I2C to STM32l151rx series microcontroller , I am able to Read X,Y,Z register content , but i want to use the inbuilt motion detection interrupt feature of LIS3DH ,using INT1 output , here is an example of doing this
http://www.ecnmag.com/articles/2013/04/one-accelerometer-interrupt-pin-both-wakeup-and-non-motion-detection Write 27h into CTRL_REG1; // Turn on the sensor with ODR = 10Hz normal mode. Write 01h into CTRL_REG2; // High-pass filter (HPF) enabled with 0.2Hz cut-off frequency for INT1 (AOI1) interrupt generation only. Write 40h into CTRL_REG3; // ACC AOI1 interrupt signal is routed to INT1 pin. Write 88h into CTRL_REG4; // Full Scale = +/-2 g with BDU and HR bits enabled. Write 00h into CTRL_REG5; // Default value. Interrupt signals on INT1 pin is not latched. Users don’t need to read the INT1_SRC register to clear the interrupt signal. // configurations for wakeup and motionless detection Write 08h into INT1_THS; // Threshold (THS) = 8LSBs * 15.625mg/LSB = 125mg. Write 32h into INT1_DURATION; // Duration = 50LSBs * (1/10Hz) = 5s. Write 95h into INT1_CFG; // Enable XLIE, YLIE and ZLIE interrupt generation, When i do this initialization it does not works , the Interrupt pin from Accelerometer signals at nearly 1hz par second , and not based on motion , but this interrupt even comes when no Initialization is done for Accelerometer , why is it interrupting at 1 Hz by default , while searching on this forum i found this thread ''iNEMO MEMS/STM32 Board
'' where author says '' I have found the solution for this.In the application note CTRL_REG3 is metioned as the register to configure interruppt on INT1 pin but the correct configuration is use CTRL_REG6 bit 7 and bit 6(I2_CLICKen and I2_INT1) will enable tap and double tap interruppts on INT2 pin.(Tip:for tuning increase sampling rate (CTRL-REG1) increase time-limit value).'' Is there really an error in datasheet , and the example given above is wrong ? the above st forum thread talks about Tap Detection , while i want settings for Motion detection interrupt .2013-08-31 08:32 AM
2013-09-17 04:17 AM
Finally i managed to enable interrupts , i use the application note AN3308 sequence for wakeup detection
1 Write A7h into CTRL_REG1// Turn on the sensor and enable X, Y, and Z// ODR = 100 Hz2 Write 00h into CTRL_REG2 // High-pass filter disabled3 Write 40h into CTRL_REG3 // Interrupt driven to INT1 pad4 Write 00h into CTRL_REG4 // FS = 2 g5 Write 08h into CTRL_REG5 // Interrupt latched6 Write10h into INT1_THS // Threshold = 250 mg7 Write 00h into INT1_DURATION // Duration = 08 Write 0Ah into INT1_CFG // Enable XH and YH interrupt generation In my case interrupts are not latched so 00h in CTRL_REG5I am getting these interrupt on INT2 and not INT1 pin , i can see the interrupts coming on INT1 in scope , but they dont generate a GPIO inerrupt on MC ,perhaps some problem with board , but when INT2 is enabled ( 0x40h in CTRL_REG6 of Accelerometer) i will get same signal on INT2 and INT1 perhaps same signal is duplicated on INT2 and i get this on GPIO interrupts ,so far its detecting motion only when the PCB board is oriented in a position parallel to earths surface , but when it is kept vertical and moved along x or y axis no interrupts are generated . I have tried enabling 6D etc while the Datasheet says that ''AOI-6D = ?01? is movement recognition. An interrupt is generate when orientation move fromunknown zone to known zone.'' But Its only Orientation Detection , and not Motion Detection Also i have tried different combination on XYZ higl low enable bits in INT1_CFG but nothing seems to work for motion detection when orientation is vertical2015-04-10 07:32 AM
#define ACCL_CTRL_REG1_DEFAULT 0x007F
#define ACCL_CTRL_REG2_DEFAULT 0x00A0
#define ACCL_CTRL_REG3_DEFAULT 0x0040 #define ACCL_CTRL_REG4_DEFAULT 0x0000#define ACCL_CTRL_REG5_DEFAULT 0x0004
#define ACCL_INT1_CFG_DEFAULT 0x007F
#define ACCL_INT1_THS_DEFAULT 0x0008 // valid values are 2, 4, 8, 16#define ACCL_INT1_DUR_DEFAULT 0x0010