2017-10-10 06:14 AM
i am working with the LSM9DS1.
I want to read the accelerometer data using interrupts. The problem is that, when i enable the 'data ready interrupt'(INT_DRDY_XL) and read and printf STATUS_REG, to see whether one or more interrupts have been generated, it gives me back 0b00000101 . But it should be 0b10000101 because a new interrupt should have been generated.
my sensor register are:
void init_accel_interrupt(void){
uint8_t reg_value =0; reg_value = 0x07 << 3; // x,y,z axis enabled write_reg(CTRL_REG5_XL,reg_value); reg_value = 0; reg_value = (0x06 << 5); // 952 Hz odr reg_value|= (0x02 << 3); // +-4g reg_value|= (0x01 << 2); // bw select according to bw[1:0] reg_value|= (0x00 << 0); //408 hz bw write_reg(CTRL_REG6_XL,reg_value); reg_value = 0; reg_value = (0x01 << 7);// high resolution reg_value|= (0x03 << 5); // cutofffrequency odr/50= 0 odr/100 =1 odr/400=3 reg_value|= (0x01 << 2); // filter enabled write_reg(CTRL_REG7_XL,reg_value);reg_value = (0x01 << 0);
write_reg(INT1_CTRL,reg_value); // data ready interrupt int1reg_value = (0x01 << 0);
write_reg(INT2_CTRL,reg_value); // data ready interrupt int2reg_value = (0x01 << 4) | (0x01 << 5) ;// open drain, active low
write_reg(CTRL_REG8,reg_value);reg_value = (0x01 << 3); // data available timer enabled
write_reg(CTRL_REG9,reg_value);}and my loop is:
while (1){
rv = read_reg(STATUS_REG_0);//
printf_P(PSTR('%i \n'),rv); rv = read_reg(STATUS_REG_1);// printf_P(PSTR('%i \n'),rv); rv = read_reg(INT_GEN_SRC_XL);// printf_P(PSTR('%i \n'),rv); _delay_ms(1);output is : 5
5
0
2017-10-10 07:28 AM
The bit IG_XL in the STATUS_REG will not be set by
data ready. Accelerometer data ready signal controls the XLDA bit.
The IG_XL bit would be set by interrupt from interrupt generator configured in INT_GEN_CFG_XL register which you don't use.