cancel
Showing results for 
Search instead for 
Did you mean: 

LSM6DSOX Interrupt registered but all mlc_out registers are empty?

TSchi.2269
Associate III

Hey!

After doing some work I connected a Nucleo-L011K4 to the STEVAL-MKI197V1 breakout sensor board with the LSM6DSOX. I am connected through SPI, loaded the configuration (header file) on it and get it running. I've also set up a GPIO on the Nucleo board that is connected to the INT1 pin of the sensor board and makes an interrupt when the INT1 of the sensor gets high. This all works and the interrupt is called when expected. However, I also want to read the code of the interrupt, which would be 0 or 4 depending on the detected movement.

I use the following code bit

lsm6dsox_all_sources_t      status;
uint8_t                     mlc_out[8];
 
lsm6dsox_all_sources_get(&dev_ctx, &status);
if (status.mlc_status.is_mlc1){
    lsm6dsox_mlc_out_get(&dev_ctx, mlc_out);
    sprintf((char*)tx_buffer, "Detect MLC interrupt code: %02X\r\n",
              mlc_out[0]);
       
    tx_com(tx_buffer, strlen((char const*)tx_buffer));
}

I use this to print out the code, ONLY when I notice the interrupt from INT1.

The problem is, that the interrupt gets detected, and it prints out, but the print code is always 00. What did I do wrong? Also, I tried other registers of mlc_out, but those others also print out 00.

7 REPLIES 7
Eleon BORLINI
ST Employee

Hi @TSchi.2269​ , supposing you are using the decision tree #1, to get the decision tree output you should read the content of MLC0_SRC (70h) register. The MLC_STATUS (15h) contains only the evidence if a change of the detected movement has occurred (e.g. if your decision tree change its output from "stationary" to "walking"). Regards

Thanks @Eleon BORLINI​  for your answer. Yes, I am using decision tree #1. As you can see from my code snippet, I also use:

 lsm6dsox_mlc_out_get(&dev_ctx, mlc_out);

Which, according to the documentation, contains the read content of ML0_SRC:

int32_t lsm6dsox_mlc_out_get(stmdev_ctx_t *ctx, uint8_t *buff)
{
  int32_t ret;
  ret = lsm6dsox_mem_bank_set(ctx, LSM6DSOX_EMBEDDED_FUNC_BANK);
  if (ret == 0) {
    ret = lsm6dsox_read_reg(ctx, LSM6DSOX_MLC0_SRC, buff, 8);
  }
  if (ret == 0) {
    ret = lsm6dsox_mem_bank_set(ctx, LSM6DSOX_USER_BANK);
  }
  return ret;
}

When doing this, I still get 0 as value. Do you know what might be the problem? My code is at LSM6DSOX level exactly the same as the lsm6dsox_STdC\example\machine_learning_core example of STM on Github. Thank you very much for all your hard work. I'm looking forward hearing from you.

@Eleon BORLINI​ Hey, I also tested it out with the 109V3 Development board. Indeed, if I do nothing, the MLC0_SRC register is 00, and when I cause the interrupt (move the board) and read the register, it gives 01. Weirdly enough, I don't get any changes, to any of the bites in mlc_out in my code.

Hi @TSchi.2269​ , can you pls check by polling the MLC_STATUS_MAINPAGE (38h) and the MLC_STATUS (15h) registers if there are events associated to the change of activity? Btw, I suggest you to check this Github library for MLC on LSM6DSOX where you can find the .h files and see if you have correctly set all the DSOX register (they are quite long but complete files, indeed, but should check the first register set and the last register set). Regards

Hey @Eleon BORLINI​ , thanks for trying to help me. Both MLC_STATUS_MAINPAGE and MLC_STATUS don't change. However, I checked your Github library link, and switched out my own made .h file for the standard activity_recognition.h file from that github library. However, I am unable to detect any change in registers as well there. When I switch out the Driver code (LSM6DSOX driver) from the github with my diver code, generated by CUBEMX, the flash memory of my board is full, so I can't try it out. You think the LSM6DSOX driver from CUBEMX might be bad? What is the most recent Driver that is working on the L011K4.

I would suggest you to check the STM32CubeL0 package: there are some example (generic) for the accelerometer, a little more detailed than the NUCLEO-L011K4 examples, at least to chek if your code is so far good. The github libraries usually don't include the whole STM32 MCU setup and initialization, so it is useful to double-check this point. I never asked you but, to be sure, are you able to read the WHO_AM_I register of the LSM6DSOX? Regards

Hey @Eleon BORLINI​ , again thank you so much for your help. I've double checked it. I'm doing it with SPI, but when I read the WHO_AM_I register, I also get 00.

I think my platform_write/platform_read functions are the culprint. My platform_write function seems to be working correctly:

static int32_t platform_write(void *handle, uint8_t reg, uint8_t *bufp,
                              uint16_t len)
{
	HAL_GPIO_WritePin(GPIOA, CS_Pin, GPIO_PIN_RESET);
	BSP_SPI1_Send(&reg, 1);
	BSP_SPI1_Send(bufp, len);
	HAL_GPIO_WritePin(GPIOA, CS_Pin, GPIO_PIN_SET);
	return 0;
}

Since the configuration seems to be correctly loaded onto the sensor. However, the read-function is the thing that gives the most problems. I cannot seem to find what is wrong with it though, since I got that from one of the examples:

static int32_t platform_read(void *handle, uint8_t reg, uint8_t *bufp,
                             uint16_t len)
{
	reg |= 0x80;
	HAL_GPIO_WritePin(GPIOA	, CS_Pin, GPIO_PIN_RESET);
	BSP_SPI1_Send(&reg, 1);
	BSP_SPI1_Recv(bufp, len);
	HAL_GPIO_WritePin(GPIOB, CS_Pin, GPIO_PIN_SET);
	return 0;
}