cancel
Showing results for 
Search instead for 
Did you mean: 

LPS22HB address?

JLee.21
Associate II

Hi.

I'm testing pressure using LPS22HB IC.

I connect GND SD0.

But LPS22HB give me address nack.

So I change address "Low" to "High", LPS22HB give me strange pressure value and not address nack.

Why do LPS22HB address strange?

Thank you.

6 REPLIES 6

Address would be 0xB8 on architectures like the STM32 where the I2C address is considered the high order 7-bits

0xB8 = (0x5C << 1)

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
JLee.21
Associate II

Thank you answer.

I know your answer.

My MCU transmit 0xB8, but LPS22HB dosen't ack.

So transmit 0xBA, LPS22HB transmits ack and pressure value.

But pressure value is strange value.

Hi @JLee.21​ , which I2C pull-up resistors are you mounting on your board? Regards

Hi, Eleon BoRLINI.

Yes. I mount I2C Pull-up(4.7k) resistors my boards.

It is near another IC with using I2C.

Also i have a question.

I'm using NRF52832.

I set

do{

    err_code = nrf_drv_twi_init(m_drv_pressure.cfg.p_twi_instance, m_drv_pressure.cfg.p_twi_cfg, twi_handler, NULL);

//    APP_ERROR_CHECK(err_code);

    if(NRF_SUCCESS != err_code)

    {

      break;

    }

    nrf_drv_twi_enable(m_drv_pressure.cfg.p_twi_instance);

  }while(0);

  nrf_delay_ms(5);//wait for loading trimming parameters

  lps22hb_reset_set(&dev_ctx, PROPERTY_ENABLE);

  do {

   lps22hb_reset_get(&dev_ctx, &rst);

  } while (rst);   

  lps22hb_SD0_SA0_set(&dev_ctx, sd0_sa0_data);

//  lps22hb_auto_add_inc_set(&dev_ctx, PROPERTY_ENABLE);

//  lps22hb_CTE_BIT_set(&dev_ctx, cte_data);

  lps22hb_block_data_update_set(&dev_ctx, PROPERTY_ENABLE);

  lps22hb_data_rate_set(&dev_ctx, LPS22HB_POWER_DOWN);

  lps22hb_one_shoot_trigger_set(&dev_ctx, PROPERTY_ENABLE);

  nrf_delay_ms(2);

//  lps22hb_low_pass_filter_mode_set(&dev_ctx, LPS22HB_LPF_ODR_DIV_2);

//  lps22hb_data_rate_set(&dev_ctx, LPS22HB_ODR_10_Hz);

   

  lps22hb_temp_data_ready_get(&dev_ctx, &reg1);

  do

  {     

    timeout--;

    if(timeout <= 0) 

    {

      NRF_LOG_DEBUG("temp timeout\r\n");

      return 0;

    }

  }while(!reg1);

  if (reg1)

  {

   memset(data_raw_temperature.u8bit, 0x00, sizeof(int16_t));

   lps22hb_temperature_raw_get(&dev_ctx, data_raw_temperature.u8bit);

//   temp = lps22hb_from_lsb_to_degc(data_raw_temperature.i16bit);

//   NRF_LOG_DEBUG("temp : "NRF_LOG_FLOAT_MARKER" ",   NRF_LOG_FLOAT(temp));

  }

  timeout = I2C_TIMEOUT;

  lps22hb_press_data_ready_get(&dev_ctx, &reg);

  do

  {     

    timeout--;

    if(timeout <= 0) 

    {

      NRF_LOG_DEBUG("pressure timeout, pressure status : %d, temp status : %d\r\n", reg, reg1);

      *pressure = old_pressure;

      return 0;

    }

  }while(!reg);

  if (reg)

  {

   memset(data_raw_pressure.u8bit, 0x00, sizeof(int32_t));

   lps22hb_pressure_raw_get(&dev_ctx, data_raw_pressure.u8bit);

*pressure = data_raw_pressure.i32bit;

    old_pressure = data_raw_pressure.i32bit;

  }

  nrf_drv_twi_disable(m_drv_pressure.cfg.p_twi_instance);

  nrf_drv_twi_uninit(m_drv_pressure.cfg.p_twi_instance);

But LPS22HB first pressure and temperature value are 0x00 after booting.

ctrl_reg(27h) has p_da(0x00) and t_da(0x01).

Next LPS22HB pressure and temperature value are ok.

Sometimes LPS22HB first pressure value 0x800 after booting.

Next LPS22HB pressure value 0x66.

How should i do?

Thank you.

Hi @JLee.21​ , it's a dummy suggestion, but I would suggest you to discard the 1st data, if you can do it. Pressure and temperature doesn't require a high ODR (output data rate) as in the case of a motion sensor or a microphone, so you could manage this issue in this way. Regards

Hi, Eleon BoRLINI.

Thank you answer.

But always LPS22HB has pressure value 0x66 after LPS22HB first pressure value 0x800.

It is removed after main power off.

I know it has complex problem, but What happened?

I have a question.

Under does code correct?

I searched I2C Bus in DT0132 Design Tip.pdf

int32_t lps22hb_SD0_SA0_set(stmdev_ctx_t *ctx, uint8_t val)

{

 uint32_t ctrl_reg;

 int32_t ret;

 ret = lps22hb_read_reg(ctx, 0x49, (uint8_t*)&ctrl_reg, 1);

 if(ret == 0){

  ctrl_reg |= (uint8_t)val;

  ret = lps22hb_write_reg(ctx, 0x49, (uint8_t*)&ctrl_reg, 1);

 }

 return ret;

}

Thank you.