The nature and physical phenomena of microcontroller numbers

Publisher:代码律动Latest update time:2023-06-05 Source: elecfans Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

Microcontroller execution instructions

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 the instruction.


Then this instruction must be stored somewhere in the microcontroller, and this place can still keep this instruction from being lost after the microcontroller is powered off. What is this place?


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.


The nature and physical phenomena of microcontroller numbers

We know that computers can perform mathematical operations. This is very difficult for us to understand. They are just electronic components. How can they perform mathematical operations?

This is how we humans do math problems such as 37+45. We first write 37 on the paper, then write 45 below, and then the brain calculates and finally writes the result. The raw materials for the calculation are 37 and 45, and the result is 82, which is 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 three lights on, how many states are there in total? Let’s take a look at the list: 000 / 001 / 010 / 011 / 100 / 101 / 110 / 111. Let's see, isn't this 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.


The meaning of microcontroller digits

Through the above experiments, we already know that the brightness of a light or the level of a line can represent two states: 0 and 1. In fact, this is a binary bit.

Therefore, we call a line a "bit", represented by BIT.

The meaning of microcontroller bytes

One wire can express 0 and 1, two wires can express the four states of 00/01/10/11, that is, it can express 0~3, and three wires can express 0~7. In computers, 8 wires are usually used to place Together, counting at the same time, it can represent a total of 256 states from 0 to 255.

These 8 lines or 8 bits are called a byte (BYTE).

The structure of microcontroller memory

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 .

A memory is like a small drawer. There are eight small grids in a small drawer. Each small grid is used to store "charges". The charges are 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 imagine the wire as a water pipe, and the charge in the small grid is like water, then it 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 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.

But a problem arises. A memory has many cells, and the lines are connected in parallel. When the charge is put in, the charge will be put into all the cells, and when the charge is released, the charge in each cell will be released. . In this case, no matter how many units the memory has, it can only hold the same number, which is of course not what we want. Therefore, a slight change in structure is required.

There needs to be a control line on each unit. If you want to put data into which unit, you give a signal to the control line of this unit. This control line turns on the switch so that the charge can flow freely. There is no signal on the control line of other units, 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 retrieve data from a certain unit, you only need to turn on the corresponding control switch.

Decoding of microcontroller memory

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.

There is a method called decoding. Let’s give a brief introduction: one line can represent 2 states, 2 lines can represent 4 states, 3 lines can represent 8 states, how many lines are needed to represent 256 states? 8 wires, so we only need 16 wires to represent 65536 states.

Chip Selection Concept of Microcontroller Memory

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, if a certain unit is always connected to these eight lines, problems will arise: for example, the value in this memory unit is 0FFH. The cell of another memory is 00H, so is this line at a high level or a low level? How to tell?

The method is very simple. When the outside 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, select the chip first, 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.

Bus concept of microcontroller

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 a data bus. The English name of the bus is BUS, which means a bus lane. Anyone can walk on it. The sixteen address lines are also connected together, called the address bus.


Reference address:The nature and physical phenomena of microcontroller numbers

Previous article:Design of A/D acquisition and data processing system based on 80C196KB microcontroller
Next article:Testing the L80C186-10 on the DIC-8032 integrated circuit test system

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号