There is a lot of knowledge behind the microcontroller!

Publisher:初入茅庐Latest update time:2020-01-30 Source: elecfansKeywords:MCU Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

Let's think about a question. When we write an instruction into the microcontroller in the programmer and then remove the microcontroller, the microcontroller can execute the instruction. Then this instruction must be saved somewhere in the microcontroller, and this place can still keep the instruction from being lost after the microcontroller loses power. Where is this place?

This place is the read-only memory inside the microcontroller, namely ROM (READ ONLY MEMORY). Why is it called read-only memory? Didn't we just write two numbers into it? It turns out that the ROM in 89C51 is an electrically erasable ROM, called FLASH ROM. We just used a programmer to write to the ROM under special conditions by an external device. Under normal working conditions of the microcontroller, data can only be read from that side and cannot be written into it, so we still call it ROM. Here are some basic concepts.


1. The nature of numbers and physical phenomena

We know that computers can perform mathematical operations, which is very difficult for us to understand. Computers? Although we don't understand their composition, they are just some electronic components. How can they perform mathematical operations? We do math problems such as 37+45 like this. First write 37 on a piece of paper, then write 45 below, then calculate in the brain, and finally write the result. The raw materials of the calculation: 37, 45 and the result: 82 are all written on paper. Where are they placed in the computer? In order to solve this problem, let's do an experiment first: There is a lamp here. We know that the lamp is either on or off, and there are two states. We can use '0' and '1' to replace these two states, and stipulate that on is '1' and off is '0'. Now put two lamps, how many states are there in total? Let's take a look at the list:


Please write down the situation of three lights by yourself: 000 001 010 011 100 101 110 111. Let's see, aren't these 000, 001, 101 the binary numbers we have learned? Originally, the on and off of the lights is just a physical phenomenon, but when we arrange them in a certain order, the on and off of the lights represent numbers. Let's abstract it a step further. Why do the lights light up? It is because the output circuit outputs a high level and the lights are powered. Therefore, the on and off of the lights can be replaced by whether the output of the circuit is a high level or a low level. In this way, numbers are connected to the high and low levels. (Please think about what other similar examples have we seen? (Navy) light language, flag language, telegraph, and even red and green lights).


2. Meaning of bits

Through the above experiment, we already know that the light of a light 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" and represent it with BIT.


3. Meaning of bytes

One wire can represent 0 and 1, two wires can represent four states: 00, 01, 10, and 11, that is, they can represent 0 to 3, and three wires can represent 0 to 7. In computers, 8 wires are usually put together and counted at the same time to represent a total of 256 states from 0 to 255. These 8 wires or 8 bits are called a byte.


How Memory Works

Memory structure

The memory is used to store data. It uses the level of electrical level to store data, that is, it actually stores the high and low levels of electrical level, rather than the numbers like 1234 that we are used to thinking of. In this way, one of our mysteries is solved. Is there nothing mysterious about computers?


As shown in the left picture above: a memory is like a small drawer, and a small drawer has eight small grids. Each small grid is used to store "charges". The charge is transmitted 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 imagine the wires as water pipes, and the charge in the small grid is like water, which is 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 storing data. If we want to store the data 12, that is, 00001100, we just need to fill the second and third small grids with charges and release the charges in the other small grids (see the right picture above). But there is a problem. Look at the right picture above. A memory has many units, and the lines are connected in parallel. When putting in charge, the charge will be put into all the units, and when releasing the charge, the charge in each unit will be released. In this way, no matter how many units the memory has, only the same number can be stored. This is certainly not what we want. Therefore, we need to make a slight change in the structure. Look at the right picture above. There is a control line on each unit. If I want to put data into a certain unit, I will give a signal to the control line of this unit, and this control line will turn on the switch, so that the charge can flow freely. There is no signal on the control line of other units, so the switch will not be turned on and will not be affected. In this way, as long as you control the control lines of different units, you can write different data to each unit. Similarly, if you want to get data from a certain unit, you just need to turn on the corresponding control switch.


Memory decoding

So, how do we control the control lines of each unit? This is not simple. Isn't it enough to lead the control lines of each unit to the outside of the integrated circuit? It is not that simple. There are 65536 units in a 27512 memory. If each line is led out, the integrated circuit must have more than 60,000 pins? No, what should we do? We need to find a way to reduce the number of lines. We have a method called decoding. Let me briefly introduce it: one line can represent 2 states, 2 lines can represent 4 states, 3 lines can represent several states, and how many lines are needed to represent 256 states? 8 states, 8 lines, so we only need 16 lines to represent 65536 states.


The concept of memory chip selection and bus

At this point, the decoding problem has been solved. Let's focus on another problem. Where do the eight wires sent to each unit come from? They are connected from the computer. Generally, these eight wires are connected to other devices in addition to a memory. So the problem comes out. Since these eight wires are not dedicated between the memory and the computer, it is not good if a certain unit is always connected to these eight wires. For example, the value in this memory unit is 0FFH and the value in another memory unit is 00H, then is this line at a high level or a low level? Isn't it necessary to fight to see who is more powerful? So we have to separate them.


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, we just turn on the switch. This set of switches is selected by three leads: the read control terminal, the write control terminal and the chip select terminal. To write data into the chip, first select the chip, then send a write signal, the switch is closed, and the transmitted data (charge) is written into the chip.


If you want to read, first select the chip, then send a read signal, close the switch, and the data is sent out. The read and write signals are also connected to another memory at the same time, but because the chip select ends are different, although there are read or write signals, there is no chip select signal, so the other memory will not "misunderstand" and open the door, causing a conflict. So will the two chips not be selected at the same time? As long as the system is well designed, it will not happen, because it is controlled by calculation, not by us. If two chips are really selected at the same time, then there is a circuit failure, which is not within the scope of our discussion.


From the above introduction, we have seen that the eight wires used to transmit data are not dedicated, but are shared by many devices, so we call it a data bus. The English name of the bus is BUS, which means bus lane, and anyone can use it. The sixteen address lines are also connected together, which is called an address bus.

Keywords:MCU Reference address:There is a lot of knowledge behind the microcontroller!

Previous article:Design of USB interface for data acquisition system based on C8051F series single chip microcomputer
Next article:The principle and application of 74HC138 38 decoder

Recommended ReadingLatest update time:2024-11-16 14:43

Some suggestions for beginners of 8-bit microcontrollers
Pre-study requirements: (1) Have a certain foundation in C language, (2) preferably have some knowledge of digital circuits   Preface: (1) As long as you are a student of the Department of Electronics or Computer Science. C language is the minimum threshold for you to get professional knowledge. Therefore, students
[Microcontroller]
Simulation and source code of 8*8LED dot matrix vertical scrolling display of "I love you"
Share an 8*8 LED dot matrix screen that scrolls vertically and displays three words "I love you" The simulation schematic is as follows The microcontroller source program is as follows: #include reg51.h unsigned char code image ={0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,          0xC3,0xE7,0xE7,0xE7,0xE7,0xE7,0xC
[Microcontroller]
Simulation and source code of 8*8LED dot matrix vertical scrolling display of
51 single chip microcomputer [five] LED dot matrix screen
I will not go into details about the concepts of display resolution, pixels, and clarity. Let's talk about the unfamiliar concept of pitch: it refers to the distance between the centers of two pixels, usually in millimeters by default. For example, p10 refers to an LED dot matrix with a pitch of 10 mm. LED P00-P07
[Microcontroller]
51 single chip microcomputer [five] LED dot matrix screen
60s countdown program for single chip microcomputer in C language
#include #define uchar unsigned char sbit P13=P1^3; sbit P14=P1^4; uchar c,i,a=60,z; flying code Numcode ={0XC0,//;0                 0XF9,//;1                 0XA4,//;2                 0XB0,//;3                 0X99,//;4                 0X92,//;5                 0X82,//;6                 0XF8,//
[Microcontroller]
How to integrate the programming function of PIC microcontroller into ATE
To do ATE, the PIC microcontroller inside the DUT needs to be programmed online. I saw someone else's statement on the Internet (author Claud Zhang), which is as follows: --------------------------------------------------------- A simple, efficient and low-cost method for programming Microchip MCUs                  
[Microcontroller]
Design of electric bicycle speed/odometer based on single chip microcomputer and photoelectric sensor
Considering the factors of environmental protection and economic conditions, electric bicycles have broad development space at present and in the future. The speedometer and odometer of electric bicycles on the market are mechanical, which seems not intuitive and convenient. If the mileage or speed value can be dire
[Microcontroller]
Design of electric bicycle speed/odometer based on single chip microcomputer and photoelectric sensor
ADC0832 analog-to-digital conversion 51 single-chip computer program and circuit diagram
#include #include intrins.h #define uint unsigned int  #define uchar unsigned char //******************adc0832************ ****************// sbit CS=P2^3; //Enable. sbit CLK=P2^2; // Clock sbit DO=P2^1; //Data output sbit DI=P2^0; //Data input char CC ="11001001";  uchar tab ={0xc0,0xf9 ,0xa4,0xb0,0x99,0x
[Microcontroller]
ADC0832 analog-to-digital conversion 51 single-chip computer program and circuit diagram
Application of CRC error checking method in serial communication between PC and 8031 ​​microcontroller
With the increasing power of data acquisition systems and the popularity of microcomputers, industrial control applications using microcomputers for data communication are becoming more and more widespread in modern industry. Especially in large-scale high-precision data acquisition systems, data analysis and calcul
[Microcontroller]
Application of CRC error checking method in serial communication between PC and 8031 ​​microcontroller
Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号