Skip to main content
Visitor II
February 19, 2019
Question

LSM303AGR Accelerometer activity/inactivity function not able to generate interrupt at INT2 pin?

  • February 19, 2019
  • 5 replies
  • 1489 views

Hi,

I am using STEVAL-MKII72V1 with LSM303AGR. I use TI CC2640R2F Launchpad to communicate to the LSM303AGR using I2C interface.

I have successfully generated LSM303AGR Interrupt 1 pin interrupt when activity threshold exceed 256 mg. I connect the LSM303AGR to a led on the TI CC2640R2F Launchpad. The led lights up whenever I move the LSM303AGR board.

But, I want to use the LSM303AGR Accelerometer activity/inactivity function, which will transition from Low Power Mode to Normal Mode. This functionality will reduce power consumption. The problem I am unable to generate a Interrupt 2 interrupt. Here is my initialization code below. The code below is a simplified version for sharing. What is the correct code initialization to enable LSM303AGR Accelerometer activity/inactivity function Interrupt 2.

// X, Y and Z-axis enable, power on mode, o/p data rate 10 Hz(0x27

LSM303AGR_CTRL_REG1_A |= 0x27;

// Full scale +/- 2g, continuous update(0x00)

LSM303AGR_CTRL_REG4_A |= 0x00;

// CTRL_REG6A(0x25H) P2_ACT Bit to 1

LSM303AGR_CTRL_REG6_A |= 0x08;

// INT2_CFG_A(0x34H) OR Combination of Interrupt Events

LSM303AGR_INT2_CFG_A |= 0x2A;

// 16 x 16mg = 256mg Threshold

LSM303AGR_Act_THS_A |= 0x0F;

// Set Activity Duration 1 LSb = (8*1[LSb]+1)/ODR

LSM303AGR_Act_DUR_A |= 0x07;

Regards,

Markel

    This topic has been closed for replies.

    5 replies

    ST Employee
    February 19, 2019

    ​Hi Markel, as regards to

    // CTRL_REG6A(0x25H) P2_ACT Bit to 1

    LSM303AGR_CTRL_REG6_A |= 0x08;

    did you try to enable also I2_INT2 (int2 interrupt on int2 pad)?

    // CTRL_REG6A(0x25H) P2_ACT Bit to 1

    LSM303AGR_CTRL_REG6_A |= 0x28

    Regards,

    Eleon

    MRobrAuthor
    Visitor II
    February 19, 2019

    Hi eleon.borlini.

    I do not enable the I2_INT2 at LSM303AGR_CTRL_REG6_A. I follow the instruction as is base from the datasheet. After I enable the I2_INT2 at LSM303AGR_CTRL_REG6_A, it still does not work.

    However after I set the values to LSM303AGR_INT2_CFG_A, LSM303AGR_INT2_THS_A, LSM303AGR_INT2_DURATION_A, now I see the Interrupt 2 working. But, I am not sure if that is the LSM303AGR ActivityInactivity functionality.

    Regards,

    Markel

    MRobrAuthor
    Visitor II
    February 20, 2019

    Hi eleon.borlini,

    Now the Interrupt 2 is working. When I move the LSM303AGR board I can see clearly the led turn on. But now the problem is when the LSM303AGR board is not moving, I see the led periodically turn on very quickly. This periodic interrupt is getting detected by TI CC2640R2F interrupt pin.

    Regards,

    Markel

    ST Employee
    February 21, 2019

    Do you get the same behavior also if you latch the interrupt setting LIR_INT2 to 1 in reg CTRL_REG5_A (24h)?

    MRobrAuthor
    Visitor II
    February 22, 2019

    Hi eleon.borlini,

    I set the LIR_INT2 to 1 at CTRL_REG4_A(24h). I move the LSM303AGR and the led turn on constantly as expected. But, I do not want to set the LIR_INT2. I want to make the LSM303AGR activity/inactivity work according to what is mentioned in the datasheet. I do the exact instruction from the datasheet, section 4.2.3. But there is no Interrupt 2 happening. So, what is the code to properly make the LSM303AGR activity/inactivity work?

    https://www.st.com/resource/en/datasheet/lsm303agr.pdf

    Regards,

    Markel

    MRobrAuthor
    Visitor II
    February 21, 2019

    Hi,

    Can I get code to properly make the LSM303AGR activity/inactivity functionality work?

    Regards,

    Markel

    Visitor II
    November 3, 2020

    I can see definitely the led turn on. But now the problem is whilst the LSM303AGR board isn't always transferring, I see the led periodically turn on very quickly guide. This periodic interrupt is getting detected by way of TI CC2640R2F interrupt pin.