Skip to main content
Visitor II
March 3, 2021
Solved

How do you configure an MIS2DH to generate an interrupt on INT1 when motion is detected?

  • March 3, 2021
  • 1 reply
  • 1295 views

I am trying to configure an MIS2DH to generate an interrupt on INT1 when the MISDH detects motion. I have code to configure the IIS2DLPC to do the same thing (it works) and I am trying to use that as a guide.

Here's the snippet of code where I am configuring the sensor based on the whoami register.

(I added the files that would be needed to actually answer the question.)

    This topic has been closed for replies.
    Best answer by Eleon BORLINI

    Hi @Louis Loving​ ,

    I would suggest you to use the IIS2DH Github repository (link) for a check on a MIS2DH-compatible device.

    An example of base configuration is the following one (for example for the wake-up interrupt on INT1, iis2dh_wake_up.c:(

     /* High-pass filter enabled on interrupt activity 1 */
     iis2dh_high_pass_int_conf_set(&dev_ctx, IIS2DH_ON_INT1_GEN);
     /* Enable HP filter for wake-up event detection
     * Use this setting to remove gravity on data output
     */
     iis2dh_high_pass_on_outputs_set(&dev_ctx, PROPERTY_ENABLE);
     /* Enable AOI1 on int1 pin */
     iis2dh_pin_int1_config_get(&dev_ctx, &ctrl_reg3);
     ctrl_reg3.i1_aoi1 = PROPERTY_ENABLE;
     iis2dh_pin_int1_config_set(&dev_ctx, &ctrl_reg3);
     /* Interrupt 1 pin latched */
     iis2dh_int1_pin_notification_mode_set(&dev_ctx, IIS2DH_INT1_LATCHED);
     /* Set full scale to 2 g */
     iis2dh_full_scale_set(&dev_ctx, IIS2DH_2g);
     /* Set interrupt threshold to 0x10 -> 250 mg */
     iis2dh_int1_gen_threshold_set(&dev_ctx, 0x10);
     /* Set no time duration */
     iis2dh_int1_gen_duration_set(&dev_ctx, 0);
     /* Dummy read to force the HP filter to current acceleration value. */
     iis2dh_filter_reference_get(&dev_ctx, &dummy);
     /* Configure wake-up interrupt event on all axis */
     iis2dh_int1_gen_conf_get(&dev_ctx, &int1_cfg);
     int1_cfg.zhie = PROPERTY_ENABLE;
     int1_cfg.yhie = PROPERTY_ENABLE;
     int1_cfg.xhie = PROPERTY_ENABLE;
     int1_cfg.aoi = PROPERTY_DISABLE;
     iis2dh_int1_gen_conf_set(&dev_ctx, &int1_cfg);
     /* Set device in HR mode */
     iis2dh_operating_mode_set(&dev_ctx, IIS2DH_HR_12bit);
     /* Set Output Data Rate to 100 Hz */
     iis2dh_data_rate_set(&dev_ctx, IIS2DH_ODR_100Hz);

    Can you please check if you have correctly configured the sensor?

    -Eleon

    1 reply

    ST Employee
    March 3, 2021

    Hi @Louis Loving​ ,

    I would suggest you to use the IIS2DH Github repository (link) for a check on a MIS2DH-compatible device.

    An example of base configuration is the following one (for example for the wake-up interrupt on INT1, iis2dh_wake_up.c:(

     /* High-pass filter enabled on interrupt activity 1 */
     iis2dh_high_pass_int_conf_set(&dev_ctx, IIS2DH_ON_INT1_GEN);
     /* Enable HP filter for wake-up event detection
     * Use this setting to remove gravity on data output
     */
     iis2dh_high_pass_on_outputs_set(&dev_ctx, PROPERTY_ENABLE);
     /* Enable AOI1 on int1 pin */
     iis2dh_pin_int1_config_get(&dev_ctx, &ctrl_reg3);
     ctrl_reg3.i1_aoi1 = PROPERTY_ENABLE;
     iis2dh_pin_int1_config_set(&dev_ctx, &ctrl_reg3);
     /* Interrupt 1 pin latched */
     iis2dh_int1_pin_notification_mode_set(&dev_ctx, IIS2DH_INT1_LATCHED);
     /* Set full scale to 2 g */
     iis2dh_full_scale_set(&dev_ctx, IIS2DH_2g);
     /* Set interrupt threshold to 0x10 -> 250 mg */
     iis2dh_int1_gen_threshold_set(&dev_ctx, 0x10);
     /* Set no time duration */
     iis2dh_int1_gen_duration_set(&dev_ctx, 0);
     /* Dummy read to force the HP filter to current acceleration value. */
     iis2dh_filter_reference_get(&dev_ctx, &dummy);
     /* Configure wake-up interrupt event on all axis */
     iis2dh_int1_gen_conf_get(&dev_ctx, &int1_cfg);
     int1_cfg.zhie = PROPERTY_ENABLE;
     int1_cfg.yhie = PROPERTY_ENABLE;
     int1_cfg.xhie = PROPERTY_ENABLE;
     int1_cfg.aoi = PROPERTY_DISABLE;
     iis2dh_int1_gen_conf_set(&dev_ctx, &int1_cfg);
     /* Set device in HR mode */
     iis2dh_operating_mode_set(&dev_ctx, IIS2DH_HR_12bit);
     /* Set Output Data Rate to 100 Hz */
     iis2dh_data_rate_set(&dev_ctx, IIS2DH_ODR_100Hz);

    Can you please check if you have correctly configured the sensor?

    -Eleon