We have a general understanding of the structure and characteristics of the microcontroller. Next, we will mainly explain how the microcontroller works and what working methods it has.
The microcontroller has four working modes: reset, program execution, low power consumption, and programming and encryption, which are introduced below.
1. Reset method
(1) Why reset?
As we all know, when a single-chip microcomputer executes a program, it always starts from address 0000H, so the CPU must be reset when entering the system, which is also called initialization; in addition, when the system is in a deadlock state due to errors in program execution or operational errors, in order to get rid of this state, it also needs to be reset, just like a computer needs to be restarted when it crashes.
(2) Principle of Reset
The method of resetting the microcontroller is actually very simple. Just add a high level on the RST pin (pin 9) that lasts for 24 oscillation cycles (that is, two machine cycles). If the crystal oscillator is 12M, calculate how long this continuous pulse takes?
(3) How to reset
There are three reset operations: power-on automatic reset, button reset and external pulse reset. Power-on automatic reset is achieved by charging the capacitor of the external reset circuit. When the power is just turned on, the capacitor C starts to charge the pull-down resistor. Since the voltage on both sides of the capacitor cannot change suddenly, the RTS terminal maintains a high level. As long as the charging time does not exceed 1ms, the automatic power-on reset of the microcontroller can be achieved, that is, the system initialization is completed when the power is turned on. In actual engineering applications, if there are no special requirements, this reset method is generally used; the button reset circuit is shown in Figure 2, which is actually based on the power-on reset with R2 and SA added. This circuit is generally used in systems that need to be reset frequently; the external pulse reset circuit is shown in Figure 3. External reset is usually used in systems with higher requirements, such as hoping that the system can be automatically reset after deadlock. External reset is realized by a special integrated circuit, which is commonly known as the "watchdog" circuit. There are many such circuits. They can not only complete the automatic reset function of the microcontroller, but also manage power supply and be used as external memory. For example, X25045, MAX813L, etc. are commonly used chips of this type.
Now let's take a look at what changes will happen inside the microcontroller after it is reset? See the table below:
(4) Status after reset
This is the state of the internal system after the microcontroller is reset. [page]
2. Program execution method
Program execution is the basic working mode of the microcontroller. Since PC=0000 after reset, the program starts executing from address 0000H. At this time, the microcontroller completes a series of operation controls according to the requirements of the instructions, such as making the LED light flash as mentioned earlier. However, in actual use, the program does not start executing from 0000H, but always arranges a jump instruction, such as LJMP START. Why is it arranged like this? We will explain it when we talk about interrupts.
3. Low power operation mode
In a battery-powered system, sometimes in order to reduce battery power consumption, a low-power mode is used when the program is not running. There are two low-power modes: standby mode and power-off mode.
The low power mode is controlled by the power control register PCON (mentioned in the previous lesson). The power control register is an 8-bit register defined bit by bit, and its format is as follows:
Among them: SMOD is the baud rate multiplication bit, used in serial communication; GF1 is the general flag bit 1; GF0 is the general flag bit 0; PD is the power-down mode bit, PD=1, enter the power-down mode; IDL is the standby mode bit, IDL=1, enter the standby mode. In other words, as long as an instruction is executed to make the PD bit or IDL bit 1, it will be fine. So how does the microcontroller enter or exit the power-down working mode and standby working mode.
1. Standby mode
2. Enter standby mode
When the instruction is used to make the IDL of the PCON register = 1, it enters the standby mode. At this time, the CPU stops working, but the clock signal is still provided to the RAM, timer, interrupt system and serial port; at the same time, the stack pointer SP, program counter PC, program status word PSW, accumulator ACC and all general registers are frozen; the current consumption of the microcontroller is reduced from 24mA to 3.7mA, which can save power consumption.
② Exit standby mode
To exit the standby mode, you can introduce an interrupt and place a RETI instruction in the interrupt program. We don't know what an interrupt is yet, but it doesn't matter. In fact, the standby mode is similar to the sleep mode when we use the computer.
(2) Power-off mode
①Enter standby mode
When the instruction is used to make the PD of the PCON register = 1, the power-down mode is entered. At this time, all operations of the microcontroller stop, and only the data in the internal RAM is retained; in the power-down mode, the power supply can be reduced to 2V, and the power consumption is only 50uA. At this time, it is equivalent to turning off the display and hard disk.
② Exit standby mode
The only way to exit the power-down mode is to reset, but the reset should be performed after the power supply voltage returns to normal. The reset time should be greater than 10mS. Before entering the power-down mode, the power supply voltage cannot be reduced. Therefore, a reliable microcontroller circuit should preferably have a power detection circuit. Obviously, the power-down mode and the standby mode are two different low-power modes. The former can reduce power consumption when there is no external event trigger, while the latter is used only when the program stops running. This is a brief introduction to the low-power mode of the microcontroller. More detailed content will be left for the next volume, because that is the work of the experts.
4. Programming and encryption methods
The programming and encryption of the microcontroller are completed by a special device, which is called a programmer or burner. There are many similar products with different functions. The XL2000 on this site is a product that integrates burning, testing, programming and simulation.
Previous article:How to improve your programming skills
Next article:Assembly language and assembly process
Recommended ReadingLatest update time:2024-11-16 19:39
- Popular Resources
- Popular amplifiers
- Wireless Sensor Network Technology and Applications (Edited by Mou Si, Yin Hong, and Su Xing)
- Modern Electronic Technology Training Course (Edited by Yao Youfeng)
- Modern arc welding power supply and its control
- Small AC Servo Motor Control Circuit Design (by Masaru Ishijima; translated by Xue Liang and Zhu Jianjun, by Masaru Ishijima, Xue Liang, and Zhu Jianjun)
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!
- 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
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- Understanding of TIMERA timing interrupt of MSP430F149
- Live broadcast has ended | ST wide bandgap high-performance silicon carbide and gallium nitride product technology and different application cases
- Huawei P50 series released: the world's first 3D nano-crystal mobile phone
- How to test the continuity of the communication harness?
- 422 to Ethernet
- Thermocouple Calibration Methods
- Please help me with a slightly more detailed analysis of this picture
- FAQ_How to choose TCXO for S2-lp
- [CB5654 Intelligent Voice Development Board Review] First Look at the Intelligent Voice Development Board
- Live broadcast at 3pm today | Keysight Technologies HDMI / DP2.0 online test seminar