11 Replies Latest reply on Nov 12, 2017 10:12 PM by udhakumar udhayakumar

    LIS2DE12 no interrupt and constant acceleration values

    Denis Thomas

      Hello,
      Firs of all thank you for your time.
      I'm currently working with a LIS2DE12 for its great low power current but unfortunately I'm not able to get any useful information from the device. I tried to active an interrupt in the idea to check movement in any direction (i just want an interrupt if the device is moving). It doesn't work but worst when I read the register of the acceleration i have always the same values (exactly the same even when moving, reversed, ...). I guess I have made some mistakes in my configuration but I was not able to find where is the problem. 

      Just below my pseudo-code. The I2C function are working correctly (I'm able to communcate with the LIS2DE12 )
      init:

       

      Check  ACCEL_WHO_AM_I
      write 0xC0 ACCEL_TEMP_CFG_REG // enable the measure of the temperature
      write  0x57 CTRL_REG1 //  100Hz & activate all the axes
      write 0x00 CTRL_REG2 // No filter
      write 0x00 CTRL_REG3 // No specific interrupt
      write 0x80  CTRL_REG4 // BDU activated for the temperature
      write 0x08 CTRL_REG5 //  Latch interrupt
      write 0x00 CTRL_REG6 // no INTERRUPT on int2
      write 0b00101010 INT1_CFG // Interrupt OR when over threshold
      write 0x16 INT1_THS  // Set the threshold
      write 0x03 INT1_DURATION // Set the duration (small one)
      write 0x00 FIFO_CTRL_REG  // bypass mode

       

       

      loop:
      check if data available ( read STATUS_REG_AUX) then

         read ACCEL_OUT_X_H,ACCEL_OUT_Y_H,ACCEL_OUT_Z_H

      check if INT1 == 1 then
            LED = 1 // to be able to see the interruption

       


      I hope that I respected the rules of this forum.
      kind regards,
      Denis

        • Re: LIS2DE12 no interrupt and constant acceleration values
          Miroslav B

          The STATUS_REG_AUX contains an information if new new temperature data are available, you should check STATUS_REG (27h) to get the information if new acceleration data are available and then read them.

          You can also share your complete code so I can check it.

            • Re: LIS2DE12 no interrupt and constant acceleration values
              Denis Thomas

              Hi,
              Thx for your quick reply. I made a mistake in my pseudo code above I check STATUS_REG in my code.
              To be honest my code is quiet the same than the one above.

              main(){

                 accelerometerInit();  // where all the config are made (pseudo code above)
                 while(1){
                 while(!isAccDataAvailable());   // checl STATUS_REG
                 delay(100);
                 accelerometerAcquire(&ax,&ay,&az);
                 delay(100);
                 if(INT1){            // check the interruption pin
                    yellowOn();
                    interruptClear();
                    delay(500);
                 }
                 else
                    ledOff();
                 }

              }

               

              char isAccDataAvailable(){
                 unsigned char a = i2c1_read1ByteRegister(ACCEL_ADDR, ACCEL_STATUS_REG);
                 return ((a & 0x0F) == 0x0F);
              }

               

              void accelerometerAcquire(float *x, float *y, float *z){
                 delay(10);
                 *x = convertAccel( i2c1_read1ByteRegister(ACCEL_ADDR, ACCEL_OUT_X_H) );
                 delay(10);
                 *y = convertAccel( i2c1_read1ByteRegister(ACCEL_ADDR, ACCEL_OUT_Y_H) );
                 delay(10);
                 *z = convertAccel( i2c1_read1ByteRegister(ACCEL_ADDR, ACCEL_OUT_Z_H) );
              }

               

              void interruptClear(){   // Read the INT1_SRC to clear the interruption if triggered.
                 i2c1_read1ByteRegister(ACCEL_ADDR, ACCEL_INT1_SRC);
              }

               

              The configuration above are correct for my purpose ?

            • Re: LIS2DE12 no interrupt and constant acceleration values
              Matt Wolfe

              I am having the same problem.  My goal is to continually receive interrupts (level changes) on the INT1 pin any time the device is moving, however I'm not receiving any interrupts at all.  I must have an error somewhere, can you please point me in the right direction?  I've set my processor to detect any level change on its interrupt pin that is connected to the LIS2DE12 INT1 pin, then I am applying the values below to the LIS2DE12.  The INT1 pin never changes level.  Can you tell me if I should pull the pin up or down externally, and do I need to do anything else to get a level change on the INT1 pin when the device moves?  

               

              write_register_value(CTRL_REG1, 0x57); // Turn on the sensor, enable X, Y and Z, ODR = 100Hz
              write_register_value(CTRL_REG2, 0x00); // High-pass filter disabled
              write_register_value(CTRL_REG3, 0x00); // No specific interrupt
              write_register_value(CTRL_REG4, 0x00); // FS = +/- 2g, disable BDU
              write_register_value(CTRL_REG5, 0x08); // Interrupt 1 pin latched, must read INT1_SRC (0x31) to clear it
              write_register_value(INT1_THS, 0x16); // Very low threshold, 0 = default
              write_register_value(INT1_DURATION, 0x03); // Minimum event duration
              write_register_value(INT1_CFG, 0x2A); // 00101010b, Interrupt OR when over threshold
              write_register_value(FIFO_CTRL_REG, 0x00); // bypass mode

                • Re: LIS2DE12 no interrupt and constant acceleration values
                  Denis Thomas

                  Hello,

                   

                  According to the datasheet the "LPEN" must be set to 1.  You should write 0x5F in the REG1, as I understand it.
                  I hope it will help you, but as it's not working for me I doubt.

                  Denis

                    • Re: LIS2DE12 no interrupt and constant acceleration values
                      Matt Wolfe

                      Thank you for pointing that out.  I gave it a try, but unfortunately it did not make a difference.  Please post back if you get it working and I will do the same. 

                        • Re: LIS2DE12 no interrupt and constant acceleration values
                          Matt Wolfe

                          I've got it working!  Using the settings below, when I read the INT1_SRC register I can see the bits changing as I move it around, and if I either leave my processor interrupt pin floating or pull it low, I will get an interrupt from the LIS2DE12 on the INT1 pin when motion occurs.  Reading the INT1_SRC register clears the interrupt until motion occurs again.  I hope this helps! 

                           

                          write_register_value(CTRL_REG1, 0x5F); // Turn on the sensor, enable X, Y and Z, ODR = 100Hz
                          write_register_value(CTRL_REG2, 0x00); // High-pass filter disabled
                          write_register_value(CTRL_REG3, 0x40); // Interrupt activity 1 drive to INT1 pin
                          write_register_value(CTRL_REG4, 0x00); // FS = +/- 2g, disable BDU
                          write_register_value(CTRL_REG5, 0x0C); // Bits D4D_INT1, LIR_INT1 - 4D detection enabled (requires 6D bit on INT1_CFG), Interrupt 1 pin latched, must read INT1_SRC (0x31) to clear it
                          write_register_value(INT1_THS, 0x16); // Very low threshold, 0 = default
                          write_register_value(INT1_DURATION, 0x03); // Minimum event duration
                          write_register_value(INT1_CFG, 0x7F); // All except AOI bit
                          write_register_value(FIFO_CTRL_REG, 0x00); // bypass mode


                          for(;;)

                          {

                             regVal = read_register_value(INT1_SRC);  // See the bits change here as you move it around

                             delay_ms(200);

                          }