cancel
Showing results for 
Search instead for 
Did you mean: 

Read lsm6dsv16x fifo using interrupts, only triggers if I remove wire from pin and put back

ACand.3
Associate III

Hey everyone,

I am new to the lsm6dsv16x sensor and I would like to set it up to read the full fifo as an interrupt vs polling due to speed.

I am following the example from github setting up my gpio as an external event for interrupt int1. 

https://github.com/STMicroelectronics/STMems_Standard_C_drivers/blob/master/lsm6dsv16x_STdC/examples/lsm6dsv16x_fifo_irq.c

But I am having an issue where the interrupt does not trigger unless I remove and put back the wire from the pin on the dev board. And only reads one or two times unless I remove the wire and put it back on the gpio. Any idea why this is happening? 

I am not sure why this is happening. I checked the pin and it is low without the imu interrupt pin, and it stays high with the interrupt pin connected. 
Not sure if I need pull ups or pull downs on the interrupt pin. 
Also, Do I need to  wake up the accelerometer when I need it? or can it stay on at all times?  

 

 

void accelerometerInit() { dev_ctx.write_reg = platform_write_two; dev_ctx.read_reg = platform_read_two; dev_ctx.handle = &hspi1; HAL_Delay(10); lsm6dsv16x_device_id_get(&dev_ctx, &whoamI); if (whoamI != LSM6DSV16X_ID) while (1); /* Restore default configuration */ lsm6dsv16x_reset_set(&dev_ctx, LSM6DSV16X_RESTORE_CTRL_REGS); do { lsm6dsv16x_reset_get(&dev_ctx, &rst); } while (rst != LSM6DSV16X_READY); /* Enable Block Data Update */ lsm6dsv16x_block_data_update_set(&dev_ctx, PROPERTY_ENABLE); /* Set full scale */ lsm6dsv16x_xl_full_scale_set(&dev_ctx, LSM6DSV16X_2g); //lsm6dsv16x_gy_full_scale_set(&dev_ctx, LSM6DSV16X_2000dps); /* * Set FIFO watermark (number of unread sensor data TAG + 6 bytes * stored in FIFO) to FIFO_WATERMARK samples */ lsm6dsv16x_fifo_watermark_set(&dev_ctx, FIFO_WATERMARK); /* Set FIFO batch XL/Gyro ODR to 12.5Hz */ lsm6dsv16x_fifo_xl_batch_set(&dev_ctx, LSM6DSV16X_XL_BATCHED_AT_3840Hz); /* Set FIFO mode to Stream mode (aka Continuous Mode) */ lsm6dsv16x_fifo_mode_set(&dev_ctx, LSM6DSV16X_STREAM_MODE); /* Set Output Data Rate */ pin_int.fifo_full= PROPERTY_ENABLE; lsm6dsv16x_pin_int1_route_set(&dev_ctx, &pin_int); lsm6dsv16x_xl_data_rate_set(&dev_ctx, LSM6DSV16X_ODR_AT_3840Hz); //lsm6dsv16x_fifo_timestamp_batch_set(&dev_ctx, LSM6DSV16X_TMSTMP_DEC_8); lsm6dsv16x_timestamp_set(&dev_ctx, PROPERTY_DISABLE); } void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin) { if(GPIO_Pin == Interrupt_From_VibrSensor_1_Pin) { getAccelerometerData(); } } void getAccelerometerData(){ int i = 0; int j = 0; uint16_t num = 0; lsm6dsv16x_fifo_status_get(&dev_ctx, &fifo_status); if (fifo_status.fifo_th == 1) { num = fifo_status.fifo_level; sprintf((char *)tx_buffer, "-- FIFO num %d \r\n", num); tx_com(tx_buffer, strlen((char const *)tx_buffer)); if (fifo_status.fifo_th == 1) { num = fifo_status.fifo_level; sprintf((char *)tx_buffer, "-- FIFO num %d \r\n", num); tx_com(tx_buffer, strlen((char const *)tx_buffer)); while (num--) { lsm6dsv16x_fifo_out_raw_t f_data; /* Read FIFO sensor value */ lsm6dsv16x_fifo_out_raw_get(&dev_ctx, &f_data); datax = (int16_t *)&f_data.data[0]; datay = (int16_t *)&f_data.data[2]; dataz = (int16_t *)&f_data.data[4]; ts = (int32_t *)&f_data.data[0]; switch (f_data.tag) { case LSM6DSV16X_XL_NC_TAG: sprintf((char *)tx_buffer, "ACC [mg]:\t%4.2f\t%4.2f\t%4.2f\r\n", lsm6dsv16x_from_fs2_to_mg(*datax), lsm6dsv16x_from_fs2_to_mg(*datay), lsm6dsv16x_from_fs2_to_mg(*dataz)); tx_com(tx_buffer, strlen((char const *)tx_buffer)); break; /*case LSM6DSV16X_GY_NC_TAG: sprintf((char *)tx_buffer, "GYR [mdps]:\t%4.2f\t%4.2f\t%4.2f\r\n", lsm6dsv16x_from_fs2000_to_mdps(*datax), lsm6dsv16x_from_fs2000_to_mdps(*datay), lsm6dsv16x_from_fs2000_to_mdps(*dataz)); tx_com(tx_buffer, strlen((char const *)tx_buffer)); break;*/ case LSM6DSV16X_TIMESTAMP_TAG: // sprintf((char *)tx_buffer, "TIMESTAMP [ms] %d\r\n", *ts); // tx_com(tx_buffer, strlen((char const *)tx_buffer)); break; default: break; } } } } }
View more

 

imu_int.PNG

 

2 REPLIES 2
Karl Yamashita
Principal

Isn't the lsm6dsv16x interrupt active low? I haven't looked at the data sheet for the lsm6dsv16x so I don't know if it's a open collector output? If it is which is more than likely, you'll need a pull-up on the interrupt pin. But also you need to change the GPIO mode to falling edge.

Don't worry, I won't byte.
TimerCallback tutorial! | UART and DMA Idle tutorial!

If you find my solution useful, please click the Accept as Solution so others see the solution.
ACand.3
Associate III

So I looked at the datasheet of the sensor and the sensor is by default push pull. 

PP_OD
Push-pull/open-drain selection on INT1 and INT2 pins. Default value: 0
(0: push-pull mode;
1: open-drain mode)

I  set up according to @Karl Yamashita and still see the same issue.