cancel
Showing results for 
Search instead for 
Did you mean: 

lis2dw12

sde c.1
Senior II

Hello,

I'm currently working with a custom board designed to read digital values from an accelerometer, specifically from the OUT_X, OUT_Y, and OUT_Z registers. However, I've encountered an issue: despite the accelerometer being physically stable, I am observing a significant number of peaks in the readings. These peaks consistently show an amplitude of around +/-250 units from the base level, which seems unusual.

For context, the values I'm observing are 16-bit, and I'm operating the device under a 2G high-speed setting with an 800Hz Output Data Rate (ODR). I'm aware that the effective resolution is 14 bits, as the values are left-justified, with the least significant 2 bits not holding valid information. Given this, I would normally expect any inaccuracies to be within +/-7 units, not the large deviations I'm seeing.

When I move the board, the readings for X, Y, and Z change as expected, which further puzzles me about these unexpected steady-state peaks. Are such peaks normal under these settings, or is there a potential issue I should be looking into?

Thank you for your insights.

 

image.png

1 ACCEPTED SOLUTION

Accepted Solutions
sde c.1
Senior II

The problem was intermittent and didn't happen often. However, when I applied a debugger at the moment the problem finally occurred, I noticed that the high byte was toggling between values when a peak occurred.

Once I saw this, the problem became clear. It had something to do with reading the registers while the output registers were updating.

Although the BDU bit was correctly set, there was another issue in the code. I also needed to set the IF_ADD_INC bit and send an additional 8 clock pulses to the SPI to read the entire 16 bits at once.

Now, everything is working perfectly!

 

View solution in original post

4 REPLIES 4
Federica Bossi
ST Employee

Hi @sde c.1 ,

Have you enabled the BDU bit in reg 21h?

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.

BDU is set.

It seems that most of the times there are no issues, and somethimes i see these spikes.

Maybe this can be vibration that i cannot feel myself...

 

Hi @sde c.1 ,

Yes, it seems a disturbance. Try to keep the device in an environment as isolated as possible.

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.
sde c.1
Senior II

The problem was intermittent and didn't happen often. However, when I applied a debugger at the moment the problem finally occurred, I noticed that the high byte was toggling between values when a peak occurred.

Once I saw this, the problem became clear. It had something to do with reading the registers while the output registers were updating.

Although the BDU bit was correctly set, there was another issue in the code. I also needed to set the IF_ADD_INC bit and send an additional 8 clock pulses to the SPI to read the entire 16 bits at once.

Now, everything is working perfectly!