Skip to main content
Visitor II
July 17, 2020
Question

LPS22HB address?

  • July 17, 2020
  • 2 replies
  • 1904 views

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.

    This topic has been closed for replies.

    2 replies

    Graduate II
    July 17, 2020

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

    0xB8 = (0x5C << 1)

    JLee.21Author
    Visitor II
    July 17, 2020

    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.

    ST Employee
    July 17, 2020

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

    JLee.21Author
    Visitor II
    July 23, 2020

    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.