Facing issue in configuring both Interrupt in LIS2DH accelerometer sensor.

I'm using the nRF9160 with the LIS2DH accelerometer and SDK version 2.5.2. In my hardware setup, INT1 is connected to GPIO 0 and INT2 to GPIO 1. I'm configuring both interrupt lines through the LIS2DH register settings, and I’ve confirmed that both INT1 and INT2 are properly enabled in the sensor registers. However, I'm using the Zephyr sensor_trigger_set() function to set up the interrupt, and it seems this function only uses INT2 by default, regardless of my INT1 configuration. As a result, INT1 is never triggered, and only INT2 works. I suspect the issue is with how the Zephyr LIS2DH driver internally maps the interrupt to INT2. Could you please clarify how to properly configure and use both INT1 and INT2 independently, and how to make sensor_trigger_set() use both INT1 & INT2 independently?

Parents
  • I think you might have misunderstood the interrupt lines (or maybe I did)

    I have used this sensor before and my understanding was that we need to treat these two interrupt lines as two different sensor events and NOT as two different DRDYs. If you are using Zephyr's driver, I think it only program one interrupt per trigger type (I am not 100% sure about it, but I think this is how the driver configures it)

    You probably have to call sensor_trigger_set twice something like below (looking at zephyr\samples\sensor\lis2dh\src\main.c)  after you have exposed those GPIOs correctly in your overlay file.

    static struct sensor_trigger trig_drdy = {
        .type = SENSOR_TRIG_DATA_READY,
        .chan = SENSOR_CHAN_ACCEL_XYZ,
    };
    static struct sensor_trigger trig_thresh = {
        .type = SENSOR_TRIG_THRESH,          /* threshold” event → INT2 */
        .chan = SENSOR_CHAN_ACCEL_XYZ,
    };
    
    sensor_trigger_set(lis2dh, &trig_drdy,   data_ready_handler);
    sensor_trigger_set(lis2dh, &trig_thresh, threshold_handler);
    

Reply
  • I think you might have misunderstood the interrupt lines (or maybe I did)

    I have used this sensor before and my understanding was that we need to treat these two interrupt lines as two different sensor events and NOT as two different DRDYs. If you are using Zephyr's driver, I think it only program one interrupt per trigger type (I am not 100% sure about it, but I think this is how the driver configures it)

    You probably have to call sensor_trigger_set twice something like below (looking at zephyr\samples\sensor\lis2dh\src\main.c)  after you have exposed those GPIOs correctly in your overlay file.

    static struct sensor_trigger trig_drdy = {
        .type = SENSOR_TRIG_DATA_READY,
        .chan = SENSOR_CHAN_ACCEL_XYZ,
    };
    static struct sensor_trigger trig_thresh = {
        .type = SENSOR_TRIG_THRESH,          /* threshold” event → INT2 */
        .chan = SENSOR_CHAN_ACCEL_XYZ,
    };
    
    sensor_trigger_set(lis2dh, &trig_drdy,   data_ready_handler);
    sensor_trigger_set(lis2dh, &trig_thresh, threshold_handler);
    

Children
Related