Skip to main content
Visitor II
March 2, 2020
Question

how to configure threhold based interrupt in LPS25HB

  • March 2, 2020
  • 1 reply
  • 1694 views

hello,

i m trying to  generate an interrupt event based on a defined threshold to wakeup the mcu from stop mode

here is my function to enable this feature

void LPS25_interrupt_Config(){
 
 Conf_reg1 |= (LPS25HB_CTRL_REG1_PD | LPS25HB_CTRL_REG1_ODR_25HZ);
 HAL_I2C_Mem_Write(&hi2c1,LPS25HB_ADDRESS_WRITE,LPS25HB_CTRL_REG1,1,&Conf_reg1,1,0xff);
 
 Conf_reg2 = (LPS25HB_CTRL_REG2_AUTOZERO);
	HAL_I2C_Mem_Write(&hi2c1,LPS25HB_ADDRESS_WRITE,LPS25HB_CTRL_REG2,1,&Conf_reg2,1,0xff);
 
 Conf_reg3=(LPS25HB_CTRL_REG3_INT_S_Pressure_LH );
 HAL_I2C_Mem_Write(&hi2c1,LPS25HB_ADDRESS_WRITE,LPS25HB_CTRL_REG3,1,&Conf_reg3,1,0xff);
 
 Interrupt_conf= (LPS25HB_INTERRUPT_CFG_LIR );
 HAL_I2C_Mem_Write(&hi2c1,LPS25HB_ADDRESS_WRITE,LPS25HB_INTERRUPT_CFG,1,&Interrupt_conf,1,0xff);
 HAL_I2C_Mem_Write(&hi2c1,LPS25HB_ADDRESS_WRITE,LPS25HB_THS_P_L,1,&Threshold_L,1,0xff);
 HAL_I2C_Mem_Write(&hi2c1,LPS25HB_ADDRESS_WRITE,LPS25HB_THS_P_H,1,&Threshold_H,1,0xff);
 HAL_I2C_Mem_Read(&hi2c1,LPS25HB_ADDRESS_READ,LPS25HB_INTERRUPT_CFG,1,&Interrupt_conf,1,0xff);
 Interrupt_conf|=(LPS25HB_INTERRUPT_CFG_PL_E | LPS25HB_INTERRUPT_CFG_PH_E);
 HAL_I2C_Mem_Write(&hi2c1,LPS25HB_ADDRESS_WRITE,LPS25HB_INTERRUPT_CFG,1,&Interrupt_conf,1,0xff);
 HAL_I2C_Mem_Read(&hi2c1,LPS25HB_ADDRESS_READ,LPS25HB_CTRL_REG1,1,&Conf_reg1,1,0xff);
 Conf_reg1 |= (LPS25HB_CTRL_REG1_DIF_E );
 HAL_I2C_Mem_Write(&hi2c1,LPS25HB_ADDRESS_WRITE,LPS25HB_CTRL_REG1,1,&Conf_reg1,1,0xff);
}

i m verifying the inetrrupt source register to check if an interrupt was generated but i get nothing

Any thoughts or suggestions on what I might be doing wrong, or have setup incorrectly.

thanks !

    This topic has been closed for replies.

    1 reply

    ST Employee
    March 18, 2020

    Hi @ATAYE.1​ , which pressure threshold for the activation of the interrupt did you set? How did you configured the LIR bit in INTERRUPT_CFG (24h) register (p. 39 of the datasheet)? Regards

    ATAYE.1Author
    Visitor II
    March 21, 2020

    hello @Eleon BORLINI thank you for replying

    I've set the pressure threshold to 2 ( THS_P_L=0x02 and THS_P_H=0 )

    and the LIR bit to 1 ( INTERRUPT_CFG= 0x07 )

    i tried to follow the Autozero mode example in the application note but i get nothing in the interrupt source register

    ST Employee
    March 24, 2020

    Hi @ATAYE.1​ , which physical event did you use to trigger the interrupt? A pressure blow or an altitude change? Regards