cancel
Showing results for 
Search instead for 
Did you mean: 

ST sensor - LPS27HHTW pressure read out problem

Wai Siang
Associate III

I would like to read out the pressure reading from this sensor, but it keep returning '0' Status.

Tools: Nucleo-767ZI, STM32CUBEIDE, STEVAL-220VI (the sensor eval)

I connect Sensor 
VDD to 3.3V,
CS pin to VDD_IO,
SDA, SCL pulled up by 4kOhm to 3.3V,
INT/DRDY pin left unconnected,
SAO address to GND.

Using Device Address = 5Ch (I did the 1 bit-shifting), I started to read 4 registers directly from Status Register 27h, together with measured pressure 28, 29, 2Ah, into an 8 bits array. Then, I compared the LSB of 27h for a '1'.

But I could never see once once of P_DA = 1. 

Or do we need to repeat 4x of "HAL_I2C_Mem_Read_IT" in order to get the reading of that 4 registers (27-2Ah)?
=================================
Can anyone share a successful read of this sensor with hardware connection and code snippets to correct my mistakes?

by the way, I have another question about the 24bits Pressure data reads out (though I haven't read out successfully), I am using a 32bits to hold the value, I saw the STM32CUBEIDE said I shall print it using "Long Decimal", however, specifier such as %ld shown a typo error. 
Does anyone know how to specify long integer or long decimal syntax correctly in this compiler?

1 ACCEPTED SOLUTION

Accepted Solutions
RhSilicon
Lead

Have you checked these registers (0Fh and 10h)? According to the Datasheet, if the communication is working, when reading the address WHO_AM_I (0Fh) it should return B3h (0B10110011), DS13489 - page 36.

In CTRL_REG1 (10h) has the ODR, default value: 000. When the ODR bits are set to '000', the device is in Power-down mode, DS13489 - page 36.

When the ODR bits are set to '000', the device is in Power-down mode. When the device is in power-down
mode, almost all internal blocks of the device are switched off to minimize power consumption. The I²C interface is still active to allow communication with the device. The content of the configuration registers is preserved and output data registers are not updated, therefore keeping the last data sampled in memory before going into power-down mode.

If the ONE_SHOT bit in CTRL_REG2 (11h) is set to '1', One-shot mode is triggered and a new acquisition starts
when it is required. Enabling this mode is possible only if the device was previously in power-down mode (ODR
bits set to '000'). Once the acquisition is completed and the output registers updated, the device automatically
enters in power-down mode. ONE_SHOT bit self-clears itself.

When the ODR bits are set to a value different than '000', the device is in Continuous mode and automatically
acquires a set of data (pressure and temperature) at the frequency selected through the ODR[2:0] bits.

Apparently the sensor starts in Power-down mode and it would be necessary to take at least One Shot, or leave it in Continuous mode to obtain some reading value.

 

View solution in original post

6 REPLIES 6
RhSilicon
Lead

Try shifting 1 bit in the address (addr << 1):

From 5Ch to B8h

Arduino has a very useful sketch for this, it scans the addresses and writes down which one to respond to, but anyway in Arduino the address goes from 0 to 127, but in the STM32 HAL it is from 128 to 255 (Over time we learn that STM32 has its particularities).

https://playground.arduino.cc/Main/I2cScanner/

forgot to mentioned, I did shifted. It is not this issue.

RhSilicon
Lead

Have you checked these registers (0Fh and 10h)? According to the Datasheet, if the communication is working, when reading the address WHO_AM_I (0Fh) it should return B3h (0B10110011), DS13489 - page 36.

In CTRL_REG1 (10h) has the ODR, default value: 000. When the ODR bits are set to '000', the device is in Power-down mode, DS13489 - page 36.

When the ODR bits are set to '000', the device is in Power-down mode. When the device is in power-down
mode, almost all internal blocks of the device are switched off to minimize power consumption. The I²C interface is still active to allow communication with the device. The content of the configuration registers is preserved and output data registers are not updated, therefore keeping the last data sampled in memory before going into power-down mode.

If the ONE_SHOT bit in CTRL_REG2 (11h) is set to '1', One-shot mode is triggered and a new acquisition starts
when it is required. Enabling this mode is possible only if the device was previously in power-down mode (ODR
bits set to '000'). Once the acquisition is completed and the output registers updated, the device automatically
enters in power-down mode. ONE_SHOT bit self-clears itself.

When the ODR bits are set to a value different than '000', the device is in Continuous mode and automatically
acquires a set of data (pressure and temperature) at the frequency selected through the ODR[2:0] bits.

Apparently the sensor starts in Power-down mode and it would be necessary to take at least One Shot, or leave it in Continuous mode to obtain some reading value.

 

It reads 179, B3h... I think I need to check out the ODR matter... 
thank you..

It all works now.
checked Who Am I, write to Control Register 1, read the Status and then 3 following pressure reading as Float,
all good now. Thank you.