FreeFall (lsm6dso32) Interrupt not resetting

Im trying to detect freefall with lsm sensor. Interupt is set, and it fires but after some 7 times, It locks up the device. Also, I added a reRoute part to the int handler but im getting -5 error code. 

Am I doing this correctly or am I missing a piece?

Regards, 

#define INT2_NODE            DT_ALIAS(int2)
#define INT2_GPIO_CONTROLLER DEVICE_DT_GET(DT_GPIO_CTLR(INT2_NODE, gpios))
#define INT2_GPIO_PIN        DT_GPIO_PIN(INT2_NODE, gpios)
#define INT2_GPIO_FLAGS      (DT_GPIO_FLAGS(INT2_NODE, gpios) | GPIO_INPUT)

const struct i2c_dt_spec* gdev;

int initialize_lsm6dso32x(const struct i2c_dt_spec* dev) {
  gdev = dev;

  uint8_t whoamI;
  lsm6dso32x_device_id_get(dev, &whoamI);

  lsm6dso32x_irq_init(gdev);
  
  return 0;
}

/* Declare the GPIO callbacks */
struct gpio_callback int2_cb_data;

void int2_callback(const struct device* dev, struct gpio_callback* cb, uint32_t pins) {
  lsm6dso32x_all_sources_t    int_status;
  lsm6dso32x_pin_int2_route_t int2_route;

  lsm6dso32x_all_sources_get(gdev, &int_status);

  // Check the free-fall interrupt status
  if (int_status.free_fall) {
    printk("Free-fall detected\n");
  }

  int2_route = (lsm6dso32x_pin_int2_route_t){0};
  int2_route.free_fall = PROPERTY_ENABLE;

  int status = lsm6dso32x_pin_int2_route_set(gdev, int2_route);
  if (status != 0) {
    printk("Failed to reRoute:%d\n", status);
  }
}

int lsm6dso32x_irq_init(const struct i2c_dt_spec* dev) {
  // Configure interrupt mode settings
  lsm6dso32x_int_mode_t int_mode_settings = {
    .active_low   = 0,
    .base_latched = 0,
    .emb_latched  = 0
  };

  int32_t status = lsm6dso32x_interrupt_mode_set(dev, int_mode_settings);
  if (status != 0) {
    printk("Failed to set interrupt mode\n");
    return status;
  }

  lsm6dso32x_ff_threshold_set(dev, LSM6DSO32X_FF_TSH_312mg);
  lsm6dso32x_ff_dur_set(dev, 10);

  // Configure INT2 route for freefall detection
  lsm6dso32x_pin_int2_route_t int2_route;
  int2_route = (lsm6dso32x_pin_int2_route_t){0};
  int2_route.free_fall = PROPERTY_ENABLE;

  status = lsm6dso32x_pin_int2_route_set(dev, int2_route);
  if (status != 0) {
    printk("Failed to route freefall to INT2\n");
    return status;
  }

  /* Ensure the GPIO device is ready */
  if (!device_is_ready(INT2_GPIO_CONTROLLER)) {
    printk("Error: %s device not ready\n", INT2_GPIO_CONTROLLER->name);
    return -1;
  }

  /* Configure the GPIOs and initialize the callbacks */
  gpio_pin_configure(INT2_GPIO_CONTROLLER, INT2_GPIO_PIN, INT2_GPIO_FLAGS);
  gpio_pin_interrupt_configure(INT2_GPIO_CONTROLLER, INT2_GPIO_PIN, GPIO_INT_EDGE_TO_ACTIVE);
  gpio_init_callback(&int2_cb_data, int2_callback, BIT(INT2_GPIO_PIN));
  gpio_add_callback(INT2_GPIO_CONTROLLER, &int2_cb_data);

  return 0; // Success
}

Parents
  • Hi,

    Can you elaborate what you mean by "locks up the device"? 

    • Do you get any errors?
    • Is the interrupt simply not triggered?
    • Do the device reset?
    • Do you see anything on the device log that indicates what is happening?
    • Have you debugged the application to see if it is stuck somewhere, if it gets into a state where it does not respond to the interrupt?

    Which GPIOs are you using?

    Best regards,
    Jørgen

  • Im getting generic error. Im using Ozone

    The target stopped in BusFault exception state.

    Reason: Unknown at 0x00049E90.

  • Hello,

    Jørgen is out of office, so I will look into this ticket.

    Can you please share the entire crash log? 

    If you got your "Unknown at 0x00049E90" from the R15 register in the crash log, can you please try to run

    arm-none-eabi-addr2line -e build\zephyr\zephyr.elf 0x00049E90

    or

    arm-zephyr-eabi-addr2line -e build\zephyr\zephyr.elf

    To use arm-none-... you need to install the GNU arm embedded toolchain. If you use the arm-zephyr-... you may be able to run it directly from the command line if you are inside the nRF Connect SDK path, but you may need to run the environment file first. This can be generated using the nRF Connect for Desktop -> Toolchain Manager, and the down facing arrow next to your NCS version. Add it to a folder in your environment path to be able to run it from anywhere. 

    Please also note that the address in the log may change when you rebuild your application, so make sure to use the address from your latest log/build. 

    Best regards,

    Edvin

Reply
  • Hello,

    Jørgen is out of office, so I will look into this ticket.

    Can you please share the entire crash log? 

    If you got your "Unknown at 0x00049E90" from the R15 register in the crash log, can you please try to run

    arm-none-eabi-addr2line -e build\zephyr\zephyr.elf 0x00049E90

    or

    arm-zephyr-eabi-addr2line -e build\zephyr\zephyr.elf

    To use arm-none-... you need to install the GNU arm embedded toolchain. If you use the arm-zephyr-... you may be able to run it directly from the command line if you are inside the nRF Connect SDK path, but you may need to run the environment file first. This can be generated using the nRF Connect for Desktop -> Toolchain Manager, and the down facing arrow next to your NCS version. Add it to a folder in your environment path to be able to run it from anywhere. 

    Please also note that the address in the log may change when you rebuild your application, so make sure to use the address from your latest log/build. 

    Best regards,

    Edvin

Children
No Data
Related