2017-04-29 09:36 PM
I am having significant difficulty in getting an LPS25HB to work. Temperature and pressure values returned by the sensor are incorrect. And although the sensor is sending the MSByte first, as expected, it is sending the LSbit first. Tht is quite a surprise. But even that data is wrong. Can anyone point me to an example project using the LPS25HB and the Cube HAL library? I am using the STM32L152, but any example will do.
2017-04-30 04:44 PM
although the sensor is sending the MSByte first, as expected, it is sending the LSbit first.
Eh?
JW
2017-05-01 08:07 AM
I am using the STMEVAL-MKI165V1 board to simulate real hardware. I forgot to tie Vdd_IO to VDD. The MSB/LSB issue is resolved. However, I am still not calculating correct pressures and temperatures. I am unable to find the problem with my code because I've found no information on what values the sensor is supposed to return, for example, at nominal ambient conditions. I've seen conflicting formulas used to convert sensor values to real pressure and temperature. A simple division by 4096 seems to be the correct method for converting pressure, but I do not get the right answer. Since the pressure MSB is sent first and winds up in RxBuffer[0], my code does swap the 24-bit contents of the buffer. As it stands now, data returned by the sensor is incorrect. I'm not convinced that I am using HAL_SPI_Transmit(), HAL_SPI_Receive() or HAL_SPI_TransmitReceive() correctly. Any examples of using the HAL to talk to this sensor? Does anyone know what pressure and temperature values the sensor returns under ambient conditions?
2017-05-01 09:07 AM
Remember that the sensor boots in spi bi directional mode. Use 4 wire mode by writing into the sensor control register to activate it. Then you should be able to read data properly. For environmental sensor, i2c bus makes more sense. Bitbang i2c on gpio can be tried out by simply rising nss, disabling spi af pins and checking which slave address the sensor responds to SA0 pin level dependent.
2017-05-01 11:21 AM
Interesting, according to the datasheet the I2C_DIS bit in CTRL_REG2 (21h) says I2C is Enabled by default??? I do not see where SPI is otherwise enabled on power up.
I am using 4-wire SPI and pulling CS low to initiate data transfers.
2017-05-01 03:59 PM
When nss is high, the sensor switch to i2c bus mode. The register i2c disable is probably for very specific case condition.