cancel
Showing results for 
Search instead for 
Did you mean: 

how to configure threhold based interrupt in LPS25HB

ATAYE.1
Associate II

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 !

7 REPLIES 7
Eleon BORLINI
ST Employee

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

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

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

Hello @Eleon BORLINI​  thank you again for replying

I inserted the sensor in a balloon

and I press the ball to increase the pressure

i m using The STEVAL-IDI003V2 evaluation platform

Regards.

Hi @ATAYE.1​ , please note that the LPS25HB can measure between 260 to 1260 hPa absolute pressure range, so it cannot be used to detect a pressure much greater than the atmospheric pressure. Which are the pressure levels you want to monitor? Regards

hello @Eleon BORLINI​ ,

i've set the threshold pressure to 1hPa 

my probleme is that the sensor isn't generating any interrupt ,

is there any order in which i have to set the registers so this could work properly ?

or am I missing something when initializing the sensor?

if you could point me to an example where they use the thrueshold based interrupt i will be very grateful

Regards

Hi @ATAYE.1​ , I believe you should set the pressure something like atmospheric pressure + threshold pressure...

Did you already check the LPS25HB examples available on Github repository?

/**
* @brief    Set the threshold tmp used for pressure interrupt generation (hPA).
* @detail   THS_P=THS_P_H&THS_P_L and is expressed as unsigned number.
P_ths(hPA)=(THS_P)/16.
* @param  *handle Device handle.
* @param  Pressure threshold in hPA
* @retval   Status [LPS25HB_ERROR, LPS25HB_OK]
*/
LPS25HB_Error_et LPS25HB_Set_PressureThreshold(void *handle, int16_t P_ths)
{
  uint8_t buffer[2];
 
  buffer[0] = (uint8_t)(16 * P_ths);
  buffer[1] = (uint8_t)(((uint16_t)(16 * P_ths)) >> 8);
 
  if(LPS25HB_WriteReg(handle, LPS25HB_THS_P_LOW_REG, 2, buffer))
    return LPS25HB_ERROR;
 
  return LPS25HB_OK;
}

Regards