The essence of this processing method is to insert some meaningful work at intervals while the program is waiting for events, so that the CPU does not wait needlessly all the time.
(2) Logical completeness
I think logical completeness is the biggest advantage of state machine programming.
I don’t know if you have ever written a small calculator program in C language. I wrote it a long time ago, and when I tested it, it was terrible! When I input calculations in a disciplined manner, the program can get correct calculation results, but if I deliberately input random combinations of numbers and operation symbols, the program always gets inexplicable results.
Later, I tried to simulate the working process of the program. The correct calculation formula was clear and the process was smooth. But when I encountered an irregular formula, I felt dizzy while walking. There were so many flags, so many The variables kept changing, and finally the analysis could no longer be carried out.
After a long time, I got to know the state machine, and then I suddenly realized that the program at that time had logical loopholes. If this calculator program is regarded as a reactive system, then a number or operator can be regarded as an event, and a calculation is a set of event combinations.
For a reactive system with complete logic, the system can handle events correctly no matter what combination of events, and the working status of the system itself is always in a knowable and controllable state. On the other hand, if the logical function of a system is incomplete, driven by certain combinations of specific events, the system will enter an unknowable and uncontrollable state, contrary to the designer's intention.
State machines can solve the problem of logical completeness.
State machine is a design method that centers on the system state and uses events as variables. It focuses on the characteristics of each state and the mutual conversion relationship between states. State transitions are precisely caused by events, so when studying a specific state, we will naturally consider the impact of any event on this state. In this way, every event that occurs in every state will be considered by us, and there will be no logical loopholes left.
Maybe everyone will think that this is empty, but practice will bring true knowledge. One day, if you really want to design a program with complex logic, I guarantee you will say: wow! State machines are really useful!
Previous article:Selection of microcontroller, a few steps that have to be mentioned
Next article:Doesn’t the microcontroller deserve to be called embedded? What is the relationship between embedded and microcontroller?
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- Rambus Launches Industry's First HBM 4 Controller IP: What Are the Technical Details Behind It?
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- C2000F2802x cyclic query button lights up LED
- GD32E231 DIY Contest (2) GD32E231C Development Environment Getting Started DEMO Test
- [NXP Rapid IoT Review] A Bluetooth BLE communication app designed for NXP IoT in the third week
- Introduction to the system reset method of Atria AT32F403A/407
- Lithium-ion battery SOC state of charge measurement
- How to calculate the input and output resistance of an operational amplifier?
- MSP430F5529 ADC analog-to-digital conversion source program
- 【Share】 RV-STAR development board transplants Chrome's offline game Little Dinosaur
- The Dragon Boat Festival Chip Coin Exchange Event has begun! Zongzi, multimeter, Huawei router... are waiting for you!
- Design and implementation of transformer test system based on MCU CPLD