2020-10-09 06:02 AM
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:
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
Solved! Go to Solution.
2020-10-16 08:32 AM
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
2020-10-09 07:14 AM
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
2020-10-10 07:30 AM
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.
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
2020-10-16 08:21 AM
Hi @SMeye.1 ,
Did you try your solution although the potential deadlock on host MCU?
-Eleon
2020-10-16 08:32 AM
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
2020-10-19 02:13 AM
Hi @SMeye.1 ,
let me please check internally for help, come back to you in case of news.
Thank you for the feedback,
-Eleon