2020-07-16 05:48 PM
2020-07-16 07:55 PM
Address would be 0xB8 on architectures like the STM32 where the I2C address is considered the high order 7-bits
0xB8 = (0x5C << 1)
2020-07-16 09:14 PM
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.
2020-07-17 12:47 AM
Hi @JLee.21 , which I2C pull-up resistors are you mounting on your board? Regards
2020-07-23 04:39 AM
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, ®1);
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, ®);
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.
2020-07-23 08:58 AM
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
2020-07-23 05:34 PM
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.