cancel
Showing results for 
Search instead for 
Did you mean: 

Peak detection on a LIS3DSH gives 0

SMeye.1
Associate II

Hi, I am working on a MEMS LIS3DSH connected via SPI to a STM32F207ZG having the following configuration:

Full scale: 2g

Operating mode: 100Hz

Filter: 800Hz

Registers:

CTRL_REG3: 0x48 (Interrupt pulsed, active high)

CTRL_REG4: 0x6F (BDU enabled, XYZ enabled, 100Hz)

CTRL_REG5: 0x00 (BW 800Hz, FS=2g)

State machine:

0693W000004JGVEQA4.png

Registers:

CTRL_REG1: 0x01 (State machine 1 enabled)

MASK_1A and MASK_1B : 0xFC (Axes X,Y and Z enabled as input for state machine)

TIM1_1 = 0x000A

TIM2_1 = 0x0010

THRS1_1: 0x55

SETT1: 0x81 (peak detection enabled)

The state machine is working as expected, after a motion the OUTW command is setting interrupt and the host MCU is reading out values. After S4 expires, state machine is returning to initial state without any additional interrupt.

The values are read from the host MCU in following order:

PEAK1

OUT_X

OUT_Y

OUT_Z

OUTS1

It is expected, that PEAK1 is holding the highest value detected within the first two states, but it is always having 0 even X,Y,Z and OUTS1 having correct values.

What am I doing wrong ?

Even Unico doesn't show any Peak values in the FSM window.

Thanks

Stephan

1 ACCEPTED SOLUTION

Accepted Solutions
SMeye.1
Associate II

Hi Eleon,

yes, using STOP state instead of CONT is the implemented solution which works. If the interrupt occurs, host MCU is reading registers (PEAK) and restarts the state machine.

In my oppinion the OUTW command is not working as described or maybe I am still wrong with that.

kind regards

Stephan

View solution in original post

5 REPLIES 5
Eleon BORLINI
ST Employee

Hi @SMeye.1​ ,

Please consider this explanation in the p.5 of the design tip DT0077 for the LIS3DSH State Machine description:

Peak detection is enabled by the P_DET in SETT1/SETT2 registers. When enabled, the temporary mask holds the bit corresponding to the axis where the peak has been found. If the temporary mask is used to control comparisons (R_TAM=0 in SETT1/SETT2), then the comparison is done on the axis where the peak has been found. The largest value is stored in the PEAK1/PEAK2 register. Peak detection is reset when the output is generated (OUTC/OUTW commands) or when masks are changed (REL, SELMA and SELSA command).

Could it be possible that you are resetting the peak value with the OUTW command? Especially if you try to read the PEAK1 register content after this command.

-Eleon

SMeye.1
Associate II

Hi Eleon,

according to AN3393 the OUTW command is setting the interrupt and waits for reading the OUTS1 register. Only then after reading OUTS1 the peak value is set to 0.

0693W000004JKtyQAG.png 

My understanding: This would be the only chance to react to a state machine interrupt and having the time to read out peak value from the host MCU before state machine continues.

This seems not to work for me and I decided to leave the state machine in STOP state which generates interrupt, read out peak value and reenable state machine by setting SM1_EN. But with this solution there is a potential risk of getting into a deadlock situation if host MCU is not recognizing the interrupt.

Thanks for help

Stephan

Hi @SMeye.1​ ,

Did you try your solution although the potential deadlock on host MCU?

-Eleon

SMeye.1
Associate II

Hi Eleon,

yes, using STOP state instead of CONT is the implemented solution which works. If the interrupt occurs, host MCU is reading registers (PEAK) and restarts the state machine.

In my oppinion the OUTW command is not working as described or maybe I am still wrong with that.

kind regards

Stephan

Hi @SMeye.1​ ,

let me please check internally for help, come back to you in case of news.

Thank you for the feedback,

-Eleon