1. Analysis of the internal structure of the microcontroller.
Let’s think about a problem. When we write an instruction into the microcontroller in the programmer, and then remove the microcontroller, the microcontroller can execute this instruction. Then this instruction must be stored somewhere in the microcontroller. place, and this place can still keep this instruction from being lost after the microcontroller is powered off. What kind of place is this? This place is the read-only memory inside the microcontroller, that is, ROM (READ ONLY MEMORY). Why call it read-only memory? Didn’t we clearly write down two numbers just now? It turns out that the ROM in the 89C51 is an electrically erasable ROM, called FLASH ROM. Just now we used a programmer to write to the ROM by an external device under special conditions. Under the normal working conditions of the microcontroller , can only be read from that side, and data cannot be written into it, so we still call it ROM.
2. Several basic concepts
1. The nature of numbers and physical phenomena
We know that computers can perform mathematical operations, which makes it very difficult for us to understand. Is it a computer? Although we don’t understand its composition, they are just some electronic components. How? Can you perform mathematical operations? This is how we do math problems such as 37+45. We first write 37 on the paper, then write 45 below, then do the calculation in our brain, and finally write the result. The raw materials of the calculation: 37, 45 and the result: 82 are all written on On paper, where is it placed on the computer? In order to solve this problem, let us first do an experiment: there is a light here. We know that the light is either on or off. There are two states. We can replace these two states with '0' and '1', It is specified as '1' if it is lit, and '0' if it is not lit. Now put two lights on, how many states will there be? Let’s take a look at the list:
Please write down the situation of 3 lights: 000 001 010 011 100 101 110 111 Let’s see, aren’t 000, 001, 101 the binary numbers we have learned? Originally, the turning on and off of the lights was just a physical phenomenon, but when we arranged them in a certain order, the turning on and off of the lights represented numbers. Let's take it a step further. Why does the light turn on? It is because the output circuit outputs a high level and energizes the lamp. Therefore, whether the light turns on or off can be replaced by whether the output of the circuit is high level or low level. In this way, the numbers are related to the high and low levels. (Please think about it, what other similar examples have we seen? (Navy’s) light language, semaphore, telegraph, even red and green lights).
2. The meaning of bits.
Through the above experiments, we already know: a light is on or the level of a line can represent two states: 0 and 1. In fact, this is a binary bit, so we call a line a "bit", represented by BIT.
3. The meaning of bytes.
One wire can express 0 and 1, two wires can express four states of 00, 01, 10, and 11, that is, it can express 0 to 3, and three wires can express 0~7. Usually in computers Putting 8 wires together and counting at the same time can represent a total of 256 states from 0 to 255. These 8 lines or 8 bits are called a byte (BYTE).
How memory works
1. Memory structure
Memory is where data is stored. It uses the high and low levels to store data, that is to say, it actually stores the high and low levels, not numbers like 1234 that we are used to thinking. In this way, one of our mysteries is solved Well, there is nothing mysterious about computers.
As shown on the left in the picture above: a memory is like a small drawer. There are eight small grids in a small drawer. Each small grid is used to store "charge". The charge is transferred in or released through the wires connected to it. As for how the charge is stored in the small grid, we don’t need to worry about it. You can think of the wire as a water pipe, and the charge in the small grid is like water, so it’s easy to understand. Each small drawer in the memory is a place to store data, which we call a "unit".
With such a structure, we can start to store data. If we want to put a data 12, which is 00001100, we only need to fill the second and third small grids with charges, and the charges in the other small grids Just let it go (see the right picture above). But a problem arises. Look at the right side of the picture above. A memory has many cells, and the lines are connected in parallel. When charges are put in, charges will be put into all cells, and when charges are released, charges will be placed in each cell. All the charges are discharged. In this case, no matter how many cells the memory has, it can only store the same number. This is of course not what we want. Therefore, we need to make a slight change in the structure. See the right side of the picture above. In each There is a control line on the unit. Which unit I want to put data into, I give a signal to the control line of this unit. This control line turns on the switch, so that the charge can flow freely, and the control lines of other units There is no signal, so the switch is not turned on and will not be affected. In this way, as long as the control lines of different units are controlled, different data can be written to each unit. Similarly, if you want to get data from a certain unit, you only need to turn it on. Just the corresponding control switch.
2. Memory decoding
So, how do we control the control lines of each unit? This is not simple. Wouldn't it be enough to lead the control lines of each unit to the outside of the integrated circuit? Things are not that simple. There are 65536 cells in a 27512 memory. If every wire is drawn out, this integrated circuit must have more than 60,000 pins? No, what should I do? Try to reduce the number of lines. We have a method called decoding. Let’s briefly introduce it: one line can represent 2 states, 2 lines can represent 4 states, 3 lines can represent several types, and how many lines are needed to represent 256 states? 8 types, 8 lines, so we only need 16 lines to represent 65536 states.
3. Memory chip selection and bus concept.
At this point, the decoding problem is solved. Let us focus on another problem. Where do the eight wires feeding each unit come from? It is connected from the computer. Generally, in addition to connecting a memory, these eight lines also need to connect other devices. The problem arises. Since these eight lines are not dedicated between the memory and the computer, it would be bad if a certain unit is always connected to these eight lines. For example, the value in this memory unit is 0FFH and another A memory cell is 00H, so is this line at a high level or a low level? Are we going to fight to see who gets hurt? So we're going to keep them separate. The method is of course very simple. When the external wires are connected to the pins of the integrated circuit, they are not directly connected to each unit. Just add a set of switches in the middle. Usually we leave the switch open. If we really want to write data to this memory or read data from the memory, just turn the switch on. This set of switches is selected by three leads: read control terminal, write control terminal and chip select terminal. To write data into the chip, first select the chip, then send a write signal, the switch is closed, and the transferred data (charge) is written into the chip. If you want to read, first select the slice, then send out the read signal, close the switch, and the data will be sent out. The read and write signals are also connected to another memory at the same time, but because the chip select terminals are different, although there is a read or write signal, there is no chip select signal, so the other memory will not "misunderstand" and open the door, causing a conflict. So will two chips be selected at the same time? As long as it is a well-designed system, it will not, because it is controlled by calculations, not by us. If two pieces are selected at the same time, it means that the circuit is faulty, and this is not our responsibility. included in the discussion.
From the above introduction, we have seen that the eight lines used to transmit data are not dedicated, but are shared by many devices, so we call it the data bus. The bus is called BUS in English, which means bus lane. , anyone can leave. The sixteen address lines are also connected together, called the address bus.
Previous article:How to realize remote monitoring and intelligent early warning based on the traffic weather station under the industrial Internet of Things
Next article:Learn the methods and 3 steps of microcontroller programming and design
- Popular Resources
- Popular amplifiers
- Virtualization Technology Practice Guide - High-efficiency and low-cost solutions for small and medium-sized enterprises (Wang Chunhai)
- Detailed explanation of big data technology system: principles, architecture and practice (Dong Xicheng)
- Handbook of Multisensor Data Fusion: Theory and Practice
- Multi-Sensor Data Fusion: An Introduction
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
- Detailed explanation of Altera series FPGA chip IP core
- Yatli AT-START-F403A unboxing photos~~
- 【SGP40 Review】->Unboxing Test
- Some summary about IAR -- Flash Loader principle
- The domestic operating system RT-Thread seems to be more powerful and can enter the automotive field
- Getting Started with CircuitPython for the Raspberry Pi Pico
- Switching Power Supply Interest Group Task 06
- AT32F4xx Standard Library BSP&Pack Application Guide
- Use of resolver decoding chip AD2S1200
- GaN goes mobile?