cancel
Showing results for 
Search instead for 
Did you mean: 

MEMS Studio FSM how to use Long Counter

LPetr.1
Senior II

I am using STEVAL-MKI109D + STEVAL-MKI238A. I have evaluated motion-stationary FSM example as it seemed closest to what we want to use for our application. It seems to work fine, however it is too sensitive and needs some upgrades.

What I want to achieve:

Setup timer (TI3) to some value such such as 5 seconds. During this 5 second period, I want to detect specific number of events above certain threshold (GNTH1). If specific number of events were detected during 5 second period, generate an interrupt and repeat over and over again. If specific number of events were not detected during that 5 seconds period, just reset the counter and repeat.

My cofiguration:

LPetr1_3-1776773120172.png



It sounds like a simple requirement but I cannot achieve it using FSM.I tried to achieve this using 2 FSM's:

 

FSM1:

LPetr1_1-1776772661939.png
FSM1 is responsible for incrementing long counter everytime the GNTH1 is reached.

 

FSM2:

LPetr1_2-1776772700006.png

FSM2 is responsible for resetting long counter. I don't really understand why the MEMS Studio forces me to put STOP command at the end of the FSM2. Will it halt the FSM2 and could that cause any issues? I have tried to remove this command and click "Write FSM configuration to sensor"  but then the STOP command automatically appears again at the end...

 

The results are below:

LPetr1_0-1776770840109.png

 

 

For some reason, the INT2 latches and does not reset. I cannot wrap my head around why it does not reset even though my FSM2 has RSTLC.

I also notice this in the datasheet:

If any of the programs makes use of the long counter through the commands described above, the FIFO must be
enabled in continuous mode. Refer to AN5909 for more details on the FIFO buffer

Does that mean I need to use FIFO?

LPetr1_5-1776773240783.png

LPetr1_7-1776773288114.png

 

I have tried to enable and select Continuous mode. When I go to FSM Testing tab and move the device and Read the FSM_LONG_COUNTER register value, I see its stuck at 0014 and its not being reset back to 0 after period so it seems that its also not working

LPetr1_0-1776773680259.png

 

I am also attaching FSM_files.zip if you want to check my FSM configuration.

So to summarize my question:

1. Why the INT2 latches when the Long counter reaches its threshold value and why does my FSM2 RSTLC
 not able to reset it? 

 

1 REPLY 1
Federica Bossi
ST Employee

Hi @LPetr.1 ,

Hello,

We checked your configuration and we mostly agree on what you did.

We would like to provide additional details on your configuration and explain the behavior you observed:

 

  • Timer 3 value 55 if FSM ODR is set to 25 Hz corresponds to 3.4s as shown into GUI not 5s
  • As you stated if any programs makes use of the long counter the FIFO must be enabled in continuous mode, this should be done inside your configuration adding 15h register write request with value 0x06 before writing FSMs configuration (see image attached and I will send you the updated configuration file in private message)
    FedericaBossi_0-1777447639864.png

     

  • Once FIFO is enabled you will no more see INT2 signal latched, instead once max long counter value is reached, INT2 will go high, on every INT status data read it will go down and again up until RSTLC command is executed. 

Best regards

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.