9720 views|19 replies

124

Posts

1

Resources
The OP
 

[Understanding of FSM finite state machine of LSM6DSOX] -- Introduction to state machine instructions, with [Chinese version instruction set] [Copy link]

 
 This post was last edited by justd0 on 2020-4-23 00:06

In the article LSM6DSOX Unboxing and Experience "Port not open & not supported" Problem Solving, I shared the process of trying to use the LSM6DSOX sensor for the first time and the solutions to the problems encountered.

In [Understanding the FSM Finite State Machine of LSM6DSOX]--Introduction to the State Machine, the essence of the FSM finite state machine in the LSM6DSOX sensor is briefly introduced.

In [Understanding the FSM Finite State Machine of LSM6DSOX]--Introduction to the Programming Module, the structure and variables of the FSM programming module are introduced in combination with the FSM interface in Unico .

In this chapter, I will share the learning of LSM6DSOX state machine instructions in combination with the official documentation , and share the instruction set descriptions that I translated piece by piece in the past two days . I hope it can help partners better use the FSM state machine to write their own programs. Let's get started ~

The instruction code is stored after the variable variable area of the LSM6DSOX state machine program block and consists of a series of states that implement the algorithm logic.

Each instruction has an 8 - bit opcode. Each opcode can implement a command instruction (CMD) or a conditional instruction ( RESET/NEXT, RNC ) . They are called program states . Multiple instructions together form the overall logic of the FSM , where:

  • Command instructions (CMD) are used to perform special tasks such as flow control , output and synchronization . Some commands require parameters, which will be executed as a separate instruction. We will discuss this in detail later.
  • Conditional instructions ( RESET/NEXT, RNC ) , composed of two conditions ( 4 -bit RESET condition and 4 -bit NEXT condition), are used to reset or continue program flow.

The instruction code has a direct impact on the LSM6DSOX registers and internal parameters of the state machine . Some instructions can also generate additional functions, such as updating status information. The following introduces the characteristics and usage of command instructions and conditional instructions respectively.

Command instruction (CMD)

Command instructions are actions that modify the flow control, output , and synchronization of the state machine behavior .

When a command is executed, it is executed immediately ( no need to update the input sample set ) , the program pointer (PP) is set to the next line, and the following actions are performed:

  • If the new line is a command instruction , this line of command will be executed immediately .
  • If the new line is a conditional instruction , the conditional judgment instruction of this line will be processed when the next input sampling value arrives.

Some commands may require parameters , which must be defined in the next line of the command .

Here we use the " STHR1 " command as an example. This command is used to dynamically change the value of threshold 1 (THRESH1) . The configuration method in Unico is as follows:

When the program pointer (PP) points to the address 0x0A in state S0 , the device recognizes the instruction code "0xAA" as the " STHR1 " command. This instruction requires two parameters, so the device does not wait for a new input sample set and directly runs the three states S0-S2 . After execution, the value of threshold 1 will be set to " 0x5640 ", which is a decimal " 100.0 ".

Conditional instructions ( RESET/NEXT, RNC )

Conditional instructions are used to reset or continue program flow. Conditional instructions are executed in a single state after a new set of input samples are ready .

The RESET condition used for reset judgment in the conditional instruction is defined in the upper 4 bits of the opcode, while the NEXT instruction used to judge the continuation is defined in the lower 4 bits of the opcode. The execution logic of the conditional instruction is shown in the figure below:

When entering the conditional instruction, the reset condition (RESET) is first determined . Only when the RESET condition is not met , the continue condition (NEXT) is determined .

When both conditions are not met , the state machine will wait for a new sampling set to arrive and then restart the judgment.

When the RESET condition is met , a state transition to the reset point occurs , that is, PP=PR .

When the RESET condition is not met and the NEXT condition is met , it will transition to the next state , that is, PP = PP+1 ;

By default, the reset point (RP) is set to the first state , but the reset point position can be changed dynamically via the " SRP/CRP " instruction .

It is worth noting that it does not make sense for the RESET and NEXT conditions to be the same condition .

There are three conditions that conditional instructions can judge:

  • Timeout : When the timer is set and the value of the timer counter TC reaches zero , the condition is met and established.
  • Threshold comparison : When the input value of the startup is higher ( or lower ) than the set threshold, the condition is met and established.
  • Zero-crossing detection : When the start input crosses the zero position , the condition is met and established.

The above are all the characteristics of imperative instructions and conditional instructions.

The FSM instruction set provides a total of 16 conditional instructions and 35 imperative instructions .

I have translated all the instruction set instructions into Chinese , and formatted them into a quick reference PDF to share with everyone.

The file is at the end of the article, but you need to reply to it to see it.

If there are any mistakes, I hope you can correct them in the comments~~

The following is a screenshot of the 35 imperative instructions and 16 conditional instructions:

Command Instructions

Conditional directives

I've been busy recently and can only work on this at night, so I translated the instruction set bit by bit while staying up late. There may be many omissions and errors. I hope you can point them out when you find them~~

I hope this can help you. Of course, if you are good at English, you can also read the official English original document directly, so it is not easy to have misunderstandings.

游客,如果您要查看本帖隐藏内容请回复

Latest reply

Hard  Details Published on 2024-7-16 10:52
 
 

94

Posts

4

Resources
2
 
Hard work
 
 
 

9702

Posts

24

Resources
3
 
Very good
 
 
 

931

Posts

3

Resources
4
 

Thank you for sharing

 
 
 

60

Posts

1

Resources
5
 
Awesome, I saw the document and it doubled my efficiency. Thanks
 
 
 

67

Posts

1

Resources
6
 
Learn, Learn
 
 
 

67

Posts

1

Resources
7
 

It feels like the host has unlimited energy!

 
 
 

280

Posts

7

Resources
8
 

Thank you for sharing

 
 
 

42

Posts

5

Resources
9
 

Very good

 
 
 

14

Posts

0

Resources
10
 

Awesome, learn from it

 
 
 

4

Posts

0

Resources
11
 

good, very

 
 
 

3

Posts

0

Resources
12
 
 
 

15

Posts

0

Resources
13
 

Learn to learn

 
 
 

11

Posts

0

Resources
14
 

Thanks for sharing, the Chinese document reading speed is high

 
 
 

11

Posts

0

Resources
15
 

In addition, there is an official Chinese version of sox, which can also be downloaded from https://www.st.com/resource/zh/application_note/an5273-lsm6dsox-finite-state-machine-stmicroelectronics.pdf

 
 
 

14

Posts

1

Resources
16
 
 
 

11

Posts

0

Resources
17
 

It is indeed a good thing, and I have worked hard to collect and organize it. I look forward to better uploads.

 
 
 

1

Posts

0

Resources
18
 
 
 

2

Posts

0

Resources
19
 

Thanks for sharing. With this and the video, I quickly learned how to use FSM.

 
 
 

2

Posts

0

Resources
20
 
 
 

Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews

Room 1530, Zhongguancun MOOC Times Building, Block B, 18 Zhongguancun Street, Haidian District, Beijing 100190, China Tel:(010)82350740 Postcode:100190

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list