Microcontrollers are a very practical course. If you simply learn theoretical knowledge without practicing, it will be difficult to fully master microcontrollers.
Although the microcontroller is an intelligent integrated chip, it is essentially an electronic component. Since it is an electronic component, it must be operated in a certain circuit to realize its function. This is like a resistor. If a resistor is placed independently, it is meaningless. Only when the resistor is connected to the circuit can its function be realized. After all, whether it is voltage division, current division, or current limiting, it depends on the detailed circuit.
Although a single-chip microcomputer integrates many circuits, it still cannot run independently. It must be connected to some external circuits to make the single-chip microcomputer run. This simplest circuit that can make a single-chip microcomputer work is called a single-chip microcomputer minimum system. In Figure
2-1
,
the AT
has
40
pins
.
Without further ado, let's analyze the circuit shown in Figure 2-1 .
First, let's take a look at the clock circuit of the microcontroller, as shown in the red circle above with the word "晶振". The clock circuit of the microcontroller is formed by connecting a crystal oscillator and two 30pF capacitors. The crystal oscillator is a component that can output a stable oscillation cycle, through which the microcontroller can have a concept of time.
However, the crystal oscillator cannot be used independently and must be used with appropriate load capacitors, otherwise errors will occur or the crystal oscillator may not work.
The load capacitor can be selected according to the instructions in the technical documentation of the microcontroller. For 51 microcontrollers, ceramic capacitors of no more than 40pF are generally selected . Since we know that the clock oscillation circuit consists of a crystal oscillator and a crystal oscillator load capacitor, why do we need to add this circuit?
Let’s look at an example:
Under normal circumstances, a person can only do one thing at a certain moment (of course, being half-hearted does not count), but a person cannot do one thing all day, so we have to arrange the things that need to be done in a certain time sequence. So what do we use to divide time? The wise ancient people used sundials to mark time very early. Through the sundial, a day is divided into 12 equal parts, which we often call hours. With the concept of hours, we can easily arrange time. The microcontroller is an intelligent device that can handle many things, so how do we arrange these things?
In order to give the microcontroller a " sundial " , we use a crystal oscillator that can output an oscillating clock. The clock pulses output by the crystal oscillator are used to arrange the work of the microcontroller. Therefore, we can make some arrangements for the microcontroller. When the first clock pulse appears, what does the microcontroller do? When the second clock pulse appears, what does the microcontroller do? ... When the nth clock pulse appears, what does the microcontroller do ? ... Continue to arrange like this, and we can use the microcontroller to achieve what we want to do. From a professional perspective, this arrangement is called programming.
Next, let's look at the reset circuit of the 51 microcontroller, which consists of a 10uF capacitor and a 4.7K resistor. Why is it wired like this? The reason is this: when designing the 51 microcontroller, it is stipulated that the 9th pin of the 51 microcontroller is the reset function pin. When there is a high level on this pin for more than two consecutive machine cycles ( more than 2us ) [Note 2 ], the microcontroller will reset. And our circuit design is that the capacitor is turned on at the moment of charging. At this moment, the current passes through the capacitor and then discharges in the direction of the resistor. At this time, the "-" end of the capacitor can have a very high potential. When it is higher than 3V , it can be considered as a high level. The charging of the capacitor takes time. When a suitable capacitor is selected, its charging time will be greater than 2us . At this time, the reset condition is established. Of course, in order to achieve a more stable reset, we often control the high level time of the reset pin of the microcontroller to be longer, usually reaching the ms level.
You may ask, why do we need to reset it?
Before I answer your question, let me ask you a few questions in return. If you can answer these questions, you will be able to find your answer.
Question 1 : When you want to do something, where do you want to start? Do you want to start from the very beginning, the middle stage, or the end stage?
Question 2 : When your machine breaks down, do you hope it can return to normal operation?
Obviously, when we start working or when something goes wrong, we all want to return to the original initial state.
Then, our answer is obvious. The function of reset is to enable the microcontroller to return to the set initial working state and start working.
Now that we know the reset and crystal oscillator circuits, let's take a look at the circuit on the right side of the microcontroller. This circuit connects the 31- pin EA of the microcontroller to the power supply VCC terminal.
In the pin definition of the microcontroller, the EA port is the enable terminal for accessing the external memory. Because a horizontal line is added to the two letters "EA" , it means that the low level is valid at this pin. (In digital circuits, this method is often used to indicate that if there is no horizontal line above the letter, it means that the high level is valid, and if there is a horizontal line, it means that the low level is valid.) That is, when the "EA" pin is at a low level, the external memory is directly accessed.
When the EA pin is at a high level, the internal memory is accessed. When the memory address to be accessed exceeds the address range of the internal memory, the corresponding address of the external memory is automatically accessed.
The microcontrollers we are using now and the microcontrollers we are studying have internal memory, and its memory space is 4kb . In order not to waste this storage space, we will directly connect the EA pin to a high level, so that the microcontroller will first run the program in the internal memory. However, there is an exception to this microcontroller, that is, the 8031 microcontroller, which is also based on the 8051 microcontroller core. However, when designing this microcontroller, the memory is not integrated into the microcontroller, and an external memory is required. At this time, the EA pin must be grounded, otherwise, the microcontroller cannot work.
People often say that the MCU is the most important part of the whole system, but I don't think so. Since it is a system, all parts of the system are unified and inseparable. Without any part, the MCU system cannot work properly. Just like in a person, other organs except the brain are not unimportant. In fact, other organs are also very important.
The microcontroller is an electronic device, so it must have a power supply to work. Otherwise, no matter how powerful you are, you are just a small " black centipede monster " that is nothing .
The 51 microcontroller we use needs to work stably in a +5V DC environment (not all microcontrollers work at +5V , some low-voltage microcontrollers work at 3.3V , and some are even lower). In a DC power supply, there are usually two wires, a positive power supply and a ground. The pin for the microcontroller to connect to +5V is 40- pin VCC , and the ground pin is 20- pin GND .
The +5V DC power supply for the microcontroller must be very stable, otherwise it may cause the microcontroller to reset frequently, which must be avoided during the normal operation of the microcontroller, unless there is a specific need or a fault occurs.
MCU clock cycle
Decades ago, due to technical reasons, the speed of microcontrollers was very slow. The clock pulses of the crystal oscillator were too fast for the microcontrollers to execute an instruction with each pulse. In order to solve this problem, our great engineers made a little improvement and set it to execute an instruction only after several pulses appeared. In this way, the speed of the microcontroller could work according to the clock.
It's like seconds are too small for ordinary people like us. It is difficult for us to be accurate to seconds in our daily work. In order to solve this problem, time concepts such as minutes and hours came into being.
In the 51 single- chip microcomputer, the pulse period of the crystal oscillator output is the pulse period, 12 pulse periods are the machine period, and the minimum working time of the single-chip microcomputer is the machine period.
Previous article:Engineers share the steps to learn MCU
Next article:Introduction to Classic MCU Types
- High signal-to-noise ratio MEMS microphone drives artificial intelligence interaction
- Advantages of using a differential-to-single-ended RF amplifier in a transmit signal chain design
- ON Semiconductor CEO Appears at Munich Electronica Show and Launches Treo Platform
- ON Semiconductor Launches Industry-Leading Analog and Mixed-Signal Platform
- Analog Devices ADAQ7767-1 μModule DAQ Solution for Rapid Development of Precision Data Acquisition Systems Now Available at Mouser
- Domestic high-precision, high-speed ADC chips are on the rise
- Microcontrollers that combine Hi-Fi, intelligence and USB multi-channel features – ushering in a new era of digital audio
- Using capacitive PGA, Naxin Micro launches high-precision multi-channel 24/16-bit Δ-Σ ADC
- Fully Differential Amplifier Provides High Voltage, Low Noise Signals for Precision Data Acquisition Signal Chain
- 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
- Why do thyristor controlled solenoid valves often break down?
- C2000 floating point calculation notes - differences between CPU and CLA and error handling techniques
- Eight magical uses of zero ohm resistors
- EEWORLD University - How to develop a 4g smart device using the new version of Gizwits Cloud platform
- Bluetooth module problem
- [Raspberry Pi Pico Review] - PWM and breathing light examples
- A Maximum Power Point Tracking (MPPT) solar charge controller for 12V and 24V solar panels
- 【Silicon Labs Development Kit Review】+DEMO Program Download
- IoT indoor environment monitor based on ESP32-S2-Kaluga-1
- EEWORLD University Hall----Kalman Filter