Issue with IMU Sensor (LSM6DSV16X) Sample Rate in Sensor Hub Mode

I am using an IMU sensor in sensor hub mode (LSM6DSV16X, LIS2MDL) with the FIFO interrupt interval set at 30 Hz. The data is sent over BLE. It works perfectly when using RTT, but when I disable debug mode, the sample rate drops to around 1 Hz.

Could someone please help me resolve this issue?

Thank you.

Parents Reply Children
  • Do you mean the nRF's ADC? In that case, what triggers the ADC interrupts?

    BR,

    Edvin

  • Yes, it is nRF's ADC. Whenever the conversion is finished, the interrupt will occur.

    static void analog_sample_work_handler(struct k_work *work)
    {
    	int ret = 0;
    	
    	
    	/* Start ADC */
    	ret = analog_read();
    	if (ret) {
    		LOG_ERR("Cannot read analog signals(err: %d)", ret);		
    	} else {
    		for(uint8_t i = 0; i < 4; i++) {
    			ret = analog_get_raw(i, &adc_raw[i]);
    			if (ret) {
    				LOG_ERR("Cannot get raw analog values(err: %d)", ret);
    				break;
    			}
    		}
    	}
    	
    	
    		
    	if(!ret) {		
    			
    		memset(tx_ble_buffer, 0, sizeof(tx_ble_buffer));  
    		sprintf((char *)tx_ble_buffer, "ADC:A1=%d,A2=%d,A3=%d,A4=%d\r\nLED:L1=%d,L2=%d,L3=%d,L4=%d\r\n",
          	adc_raw[0],adc_raw[1],adc_raw[2],adc_raw[3],led_state[0],led_state[1],led_state[2],led_state[3]);
    				
    		LOG_INF("BLE Tx data : %s", tx_ble_buffer);	
    			
    		ret = ble_send(tx_ble_buffer, strlen(tx_ble_buffer));	
    		if (ret) {
    			LOG_ERR("Cannot send ADC/LED data via BLE");	
    		}		
    	}
    
    	k_work_reschedule(k_work_delayable_from_work(work), K_MSEC(ANALOG_SAMPLE_INTERVAL));
    }
    
    static void on_nus_connect(struct k_work *item)
    {
    	ARG_UNUSED(item);	
    
    	
    	
    #if !(IMU_SIMULATION)
    
    	gpio_pin_interrupt_configure_dt(&tap_int, GPIO_INT_EDGE_TO_ACTIVE);
    	gpio_pin_interrupt_configure_dt(&fifo_int, GPIO_INT_EDGE_TO_ACTIVE);
    	
    
    	/* IMU out of low power mode */
    	int ret = imu_set_low_power(false);
    	if (ret) {
    		LOG_ERR("Cannot get IMU out of low power(err: %d)", ret);		
    	}
    #endif	
    	
    	
    	/* Schedule analog signal processing */
    	k_work_schedule(&analog_sample_work, K_MSEC(ANALOG_SAMPLE_INTERVAL));
    		
    }
  • Can you set up the application so that it shows the issue that you are seeing without the actual sensor, then .zip it and upload it here?

    Best regards,

    Edvin

  • Please find attached your requested file. If you run and connect to the BLE central, you can see the data rate difference on the BLE central's output on the terminal when RTT is connected and disconnected.

    Thank you,

    Saeed

    nrf5340_imu_adc_led_ble_Apr5.zip

  • Hello,

    The project that you sent doesn't have RTT logging enabled. Are you sure that you are seeing the issue with that exact application, without any modifications? It also seems like IMU_SIMULATION was set to 0. Either way, closing the RTT viewer didn't impact the rate at which the notifications are coming in, as you can tell from the timestamps here, from after closing the RTT window. 

Related