cancel
Showing results for 
Search instead for 
Did you mean: 

Can't read status of 6D registers

JBrio.1
Associate II

I have enabled the conditions needed to turn on the 6D orientation, and tried to read the registers according to these files: https://os.mbed.com/teams/ST/code/LSM6DSL//file/77ec4781b110/LSM6DSL_acc_gyro_driver.c/ and https://os.mbed.com/teams/ST/code/LSM6DSL//file/77ec4781b110/LSM6DSL_acc_gyro_driver.h/

Can anyone help me?

4 REPLIES 4
Eleon BORLINI
ST Employee

Hi @JBrio.1​ , but are you not able to read the status register, or to properly configure and raise the 6D interrupt? I suggest you to check the C code online examples on github for the LSM6DS3 device, which in terms of embedded digital feature is same as the LSM6DSL. In particular, the lsm6ds3_orientation.c file. Here below the part of the code that should be of your interest.

Configuration part:

 /* Restore default configuration */
  lsm6ds3_reset_set(&dev_ctx, PROPERTY_ENABLE);
  do {
    lsm6ds3_reset_get(&dev_ctx, &rst);
  } while (rst);
 
  /* Set XL Output Data Rate */
  lsm6ds3_xl_data_rate_set(&dev_ctx, LSM6DS3_XL_ODR_416Hz);
 
  /* Set 2g full XL scale */
  lsm6ds3_xl_full_scale_set(&dev_ctx, LSM6DS3_2g);
 
  /* Set threshold to 60 degrees */
  lsm6ds3_6d_threshold_set(&dev_ctx, LSM6DS3_DEG_60);
 
  /* Use HP filter */
  lsm6ds3_xl_hp_path_internal_set(&dev_ctx, LSM6DS3_USE_HPF);
 
  /* LPF2 on 6D function selection */
  lsm6ds3_6d_feed_data_set(&dev_ctx, LSM6DS3_LPF2_FEED);
 
  /* Enable interrupt generation on 6D INT1 pin */
  lsm6ds3_pin_int1_route_get(&dev_ctx, &int_1_reg);
  int_1_reg.int1_6d = PROPERTY_ENABLE;
  lsm6ds3_pin_int1_route_set(&dev_ctx, &int_1_reg);

Activity loop section:

/* Wait Events */
  while(1)
  {
    lsm6ds3_all_src_t all_source;
 
    /* Check if 6D Orientation events */
    lsm6ds3_all_sources_get(&dev_ctx, &all_source);
    if (all_source.d6d_src.d6d_ia)
    {
      sprintf((char*)tx_buffer, "6D Or. switched to ");
      if (all_source.d6d_src.xh)
        strcat((char*)tx_buffer, "XH");
      if (all_source.d6d_src.xl)
        strcat((char*)tx_buffer, "XL");
      if (all_source.d6d_src.yh)
        strcat((char*)tx_buffer, "YH");
      if (all_source.d6d_src.yl)
        strcat((char*)tx_buffer, "YL");
      if (all_source.d6d_src.zh)
        strcat((char*)tx_buffer, "ZH");
      if (all_source.d6d_src.zl)
        strcat((char*)tx_buffer, "ZL");
      strcat((char*)tx_buffer, "\r\n");
      tx_com(tx_buffer, strlen((char const*)tx_buffer));
    }
  }
}

Regards

JBrio.1
Associate II

Thank you for these @Eleon BORLINI​ , but I was able to read the status of the 6D Orientation with my previous firmware. Loading them now does not work anymore. I tried to give the firmware to my colleague with the same circuit and it worked for him. Probably the LSM6DSL is not functioning. Is it possible that I can troubleshoot this thru some code? If not, then I think the only solution is thru the hardware.

Uhm... but does your colleague have the same board as yours but with another LSM6DSL? And is the LSM6DSL the only device not working or just the 6D interrupt is not raised? You can check if you are able to read at least the WHO_AM_I (0Fh) and get back 6Ah value... Regards

uh I may already have the question "answered" HERE... so you are not even receiving the nack command in the I2C case... could you check by HW and then in case remove your LSM6DSL from you board and solder another LSM6DSL? Not so easy, I know... Regards