cancel
Showing results for 
Search instead for 
Did you mean: 

LSP22HB having trouble with ONE-SHOT mode

chriskot
Associate II

I am using the LSP22HB on an I2C bus. I can read the "who am i" register and get the expected value. I can also read various configuration registers and see the default values. So, I believe I am communicating with the device.

I don't set any registers since it seems the default values have the device in power down mode which is needed for ONE_SHOT operation. To get the pressure and temperature values I do the following steps:

1. Write to CTRL_REG2 the value 0x11. This sets the IF_AUTO_INC and the ONE_SHOT bits. I am under the impression the ONE_SHOT bit starts the operation to get the pressure and temperature.

2. I loop on reading the CTRL_REG2 and check the ONE_SHOT bit waiting for it to go to zero. This should indicate that the readings are now available.

3. I then read the pressure and temperature registers. I get values but they are not correct. I have tried both multi-register access to get all the values in one I2C interaction and looping through and just getting one pressure and temperature register at a time. Neither seems to give reasonable date.

What am I doing wrong in using the ONE_SHOT mode?

Is there sample code that uses ONE_SHOT mode available?

Ancilliary information:

1. The T_DA and P_DA bits in the STATUS register which are supposed to indicate valid measurements are available never go to 1.

2. I did at one time have this setup using FIFO's and got reasonable values. However, I don't need all that information. It is more important to use less power and get the values every once in a while, like once a minute. Getting values every second or faster just isn't needed here and saving power is more important

Thanks

Chris

1 ACCEPTED SOLUTION

Accepted Solutions
Federica Bossi
ST Employee

Hi @chriskot ,

You can use our PID Example on github.

Let me know if this helps and solves your problem.

In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.

View solution in original post

3 REPLIES 3
Federica Bossi
ST Employee

Hi @chriskot ,

You can use our PID Example on github.

Let me know if this helps and solves your problem.

In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.

Thanks for the pointer I'll check it out and let you know.

Thanks

Chris

chriskot
Associate II

I was able to look at the code you pointed to and I am getting reasonable numbers for temperature and barometric pressure now.

I can't say I know exactly what I was doing wrong. But I did notice these issues:

1. I was looking at the FIFO_STATUS register instead of the STATUS register. Certainly a cut and paste issue from when I had this working using the FIFO. Once I changed the register value I was getting information that the temperature and the pressure acquisition had occurred.

2. Had the endianness wrong for my processor.

One point is the data sheet makes this recommendation about CTRL_REG2

1. It is recommend to use a single-byte read (with IF_ADD_INC = 0) when output data registers are acquired
without using the FIFO. If a read of the data occurs during the refresh of the output data register, it is
recommended to set the BDU bit to ‘1’ in CTRL_REG1 (10h) in order to avoid mixing data.

While the sample code does set BDU it doesn't seem to clear IF_ADD_INC. Since ONE_SHOT doesn't seem to use the FIFO it seems you would want this bit cleared. In my code I have cleared IF_ADD_INC but I don't think that made any difference.

@Federica Bossi Thanks very much for the pointer to the sample code.

Thanks

Chris