Microcontrollers (Microcontrollers) is an integrated circuit chip that uses a very large-scale integrated circuit technology to have a central processing unit CPU with data processing capability, random access memory RAM, read-only memory ROM, various I/O ports and interrupt systems, and timers. Functions such as a counter/counter (possibly including a display driver circuit, a pulse width modulation circuit, an analog multiplexer, an A/D converter, etc.) integrated into a small piece of silicon to form a small and complete microcomputer system in the industry The control field is widely used. From the 1980s, from the then 4-bit, 8-bit microcontroller, to the current 300M high-speed microcontroller.
How does the microcontroller start cold?The cold start of the MCU is very simple, power off, and then power on, after a normal reset, the cold start is successful. The cold start of the MCU is actually a technical term, which means that the MCU starts up from the most primitive state. Achieving this goal will vary depending on the internal structure of the microcontroller. Next, we will use the STC12 series MCU cold start and hot start to analyze:
Cold start - refers to re-powering in the power off state. Cold boot is the download signal in order to detect the chip at the beginning of the download process. If there is, download it; if not, execute the original program.
Hot start - means that it is already in the power-on state, adding a reset signal to the reset terminal (and other types of reset), and the program is re-run.
How to judge is cold start, hot start?It can be judged by querying the POF bit in the PCON register. After the microcontroller is powered on and cold-started, the POF bit becomes 1, which can be cleared by software.
Actual judgment flow chart:
About cold boot download and reset of stc51The Stc MCU has a factory-cured program. The function of this program is to detect whether the serial port should download the program. If not, the user program in the MCU is executed. Run this program every time you start it, which is why you need to cold start each time you download. After the reset, the MCU starts from the address 0000H, and the address 0000H points to the main program entry, that is, the main function, that is, the user program downloaded on the chip, and does not execute the program that has been solidified before the detection serial port. This is why the microcontroller needs a cold boot every time it is downloaded, and the reset does not work. Note that the macros in front of the program define what does not take up system time, so the main program is the main function.
There is a way for users who need to power up and start immediately. The STC MCU can be set to start downloading when P1.0/P1.1 is low when powering up, otherwise the user program will be executed directly. This method is fast, you don't have to wait for the time before detecting the serial port. A cold start of the stc microcontroller is a must and a reset circuit is not required, whether it is a cold start or a manual start. That is, you want to download the program must be cold start, and there is no reset circuit. However, there must be a reset circuit on the minimum system board, whether it is a power-on reset, or a power-on plus manual reset. Although there is no difference in some simple programs, because the reset operation will affect some special registers, there is no reset. An error occurs when the function is executed again. After the MCU is powered off, it will continue to execute from the main function. It may be that the address automatically returns to 0000H after the MCU is powered off, but the values ​​in those special registers will not change.
For the power-on reset, it looks like the circuit will not have current flowing, but at the moment of power-on, there is a process of charging the capacitor. During this process, a positive pulse will appear on the rst port, as long as the pulse is kept for more than 1ms, the microcontroller can be reset.
The reset operation of the microcontroller causes the microcontroller to enter the initialization state, which includes making the program counter PC = 0000H, which indicates that the program starts execution from the 0000H address unit. After the MCU is cold-started, the on-chip RAM is a random value. The reset operation in the operation does not change the contents of the on-chip RAM area. The state after the reset of the 21 special function registers is the determined value, as shown in the following table.
It is worth pointing out that remembering the main state after resetting some special function registers is very necessary to understand the initial state of the microcontroller and reduce the initialization part of the application. Description: The symbol * in the table is a random state; A=00H, indicating that the accumulator has been cleared;
PSW=00H, indicating that the register 0 group is the working register group;
SP=07H, indicating that the stack pointer points to the on-chip RAM 07H byte unit. According to the first-and-after-press law of the stack operation, the first pressed content is written into the 08H unit;
Po-P3=FFH, indicating that 1 has been written to each port line. At this time, each port can be used for both input and output; IP=×××00000B, indicating that each interrupt source is at low priority; IE=0× ×00000B, indicating that each interrupt is turned off;
System reset is the first step in any microcomputer system execution, bringing the entire control chip back to the default hardware state. The reset of the 51 MCU is controlled by the RESET pin. After this pin is connected to the high level for more than 24 oscillation cycles, the 51 MCU enters the internal reset state of the chip and waits until the RESET pin. After turning low, it is checked whether the EA pin is high or low. If it is high, the internal program code is executed. If it is low, the external program will be executed.
When the 51 MCU resets the system, it sets some important internal registers to specific values, and the internal RAM does not change.
Nanning Ousibang Information Technology Co., Ltd. , https://www.ousibangvape.com