cancel
Showing results for 
Search instead for 
Did you mean: 

LSM9DS1: Get no Interrupt without polling

Ole Thomsen
Associate II

Hi there,

I'm tring to use the lsm9ds1 with all three sensors. Because polling is too comutational expensive I want to use interrupts. But they only work for me in combination with polling.

I have defind the pins PB5-7 for the interrupts on my Nucelo-F072RB and sample with 119Hz for the accelerometer and the gyroscope and 80Hz for the magnetometer.

The polling looks like this:

while (1) {
	HAL_I2C_Mem_Read(&hi2c1, LSM9DS1_IMU_I2C_ADD_H, LSM9DS1_STATUS_REG, 1, &ctrl_imu, 1, timeout);
	HAL_I2C_Mem_Read(&hi2c1, LSM9DS1_MAG_I2C_ADD_L, LSM9DS1_STATUS_REG_M, 1, &ctrl_mag, 1, timeout);
		//new acc data
		if((ctrl_imu & 1)!=0){
			counter[0]++;
			status = HAL_I2C_Mem_Read(&hi2c1, LSM9DS1_IMU_I2C_ADD_H, LSM9DS1_OUT_X_L_XL, 1, data_acc, 6, timeout);
		}
		//new gyro data
		if((ctrl_imu & 2)!=0){
			counter[1]++;
			status = HAL_I2C_Mem_Read(&hi2c1, LSM9DS1_IMU_I2C_ADD_H, LSM9DS1_OUT_X_L_G, 1, data_gyro, 6, timeout);
		}
		//new mag data
		if((ctrl_mag & 8)!=0){
			counter[2]++;
			status = HAL_I2C_Mem_Read(&hi2c1, LSM9DS1_MAG_I2C_ADD_L, LSM9DS1_OUT_X_L_M, 1, data_mag, 6, timeout);
}

The data are read correctly and the counter is increasing with the correct samplerate.

I tried to use an interrupt instead:

void HAL_GPIO_EXTI_Callback (uint16_t GPIO_Pin){
 
	if(GPIO_Pin == GPIO_PIN_5){
		counter_mag += 1;
		status = HAL_I2C_Mem_Read(&hi2c1, LSM9DS1_MAG_I2C_ADD_L, LSM9DS1_OUT_X_L_M, 1, data, 6, timeout);
	}
	else if(GPIO_Pin == GPIO_PIN_6){
		counter_gyr += 1;
		status = HAL_I2C_Mem_Read(&hi2c1, LSM9DS1_IMU_I2C_ADD_H, LSM9DS1_OUT_X_L_G, 1, data, 6, timeout);
	}
	else if(GPIO_Pin == GPIO_PIN_7){
		counter_acc += 1;
		status = HAL_I2C_Mem_Read(&hi2c1, LSM9DS1_IMU_I2C_ADD_H, LSM9DS1_OUT_X_L_XL, 1, data, 6, timeout);
	}
}

the corresponding counters have the same values, but without the polling no new interrupt is send and I don't have an idea why, because I can't see any dependencies.

1 ACCEPTED SOLUTION

Accepted Solutions
Ole Thomsen
Associate II

Nevermind, I found the bug. I have configure my interrups with an falling edge, because https://learn.sparkfun.com/tutorials/lsm9ds1-breakout-hookup-guide/all said, that DRDY would go low for new data, but instead it is active high.

View solution in original post

1 REPLY 1
Ole Thomsen
Associate II

Nevermind, I found the bug. I have configure my interrups with an falling edge, because https://learn.sparkfun.com/tutorials/lsm9ds1-breakout-hookup-guide/all said, that DRDY would go low for new data, but instead it is active high.