MCU internal storage structure

Publisher:seanxnieLatest update time:2015-03-26 Source: diangon Keywords: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 the instruction must be saved somewhere in the microcontroller, and this place can still keep the instruction after the microcontroller loses power. What 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 in 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, it can only be read from that side, and data cannot be written in, so we still call it ROM.

   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, 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 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:

 

state
Express
0 0
0 1
1 0
1 1

  Please write down the situation of the three lights yourself 000 001 010 011 100 101 110 111

 

  Let's take a look. Aren't 000, 001, and 101 the binary numbers we have learned? Originally, the on and off of the lights is just a physical phenomenon, but when we put them in a better order, the on and off of the lights represent numbers. Let's abstract it a step further. Why do the lights light up? Looking at circuit 1, it is because the output circuit outputs a high level and powers the lights. 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 routines we have seen? (Navy) Light language, flag language, telegraph, and even red and green lights)

What is a bit: 
  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.

What is a byte:
  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-7. In computers, 8 wires are often put together and counted at the same time, which can represent 256 states from 0 to 255. These 8 wires or 8 bits are called a byte. Don't ask me why it is 8 instead of other numbers, because I don't know either. (The computer world is a man-made world, not a natural world. You can't ask why for many things. You can only say: it is a rule. Everyone should also pay attention to this issue in the future learning process)

How memory works:

1. 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?

 


figure 2

image 3

  Let's look at Figure 2. There is such a memory in the microcontroller. This is a schematic diagram of a memory: 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 have to worry about it. You can imagine the wires as water pipes, 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 in a data 12, that is, 00001100, we just need to fill the second and third small grids with charge, and release the charge in other small grids (see Figure 3). But there is a problem. See Figure 2. A memory has many units, and the lines are connected in parallel. When the charge is put in, the charge will be put into all units, and when the charge is released, the charge in each unit will be released. In this way, no matter how many units the memory has, it can only store the same number, which is certainly not what we want. Therefore, we need to make a slight change in the structure. See Figure 2. 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, and 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. [page]

2. 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? Things are not that simple. There are 65536 units in a 27512 memory. If each line is led out, this 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.

(Figure 4)

3. 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, as shown in Figure 4. 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 solution 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 (refer to Figure 4). Usually we keep the switch closed. If we really want to write data to this memory or read data from the memory, we just need to 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 transmitted data (charge) is written into the chip. If you want to read, first select the chip, then send a read signal, the switch is closed, and the data is sent out. Note Figure 4, 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 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 what if two chips are selected at different times? As long as it is a well-designed system, 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.

Classification of semiconductor memory

  According to the function, it can be divided into two categories: read-only memory and random access memory. The so-called read-only, literally means that you can only read from it, not write into it. It is similar to our books. After it is sent to us, we can only read the contents inside and cannot change the contents of the book at will. The abbreviation of read-only memory is ROM (READ ONLY MEMORY)

The so-called random access memory can be rewritten at any time, and the data in it can also be read out. It is similar to our blackboard. I can write things on it at any time, and I can also erase it with an eraser and rewrite it. The abbreviation of random access memory is RAM (Random Access Memory). The abbreviations of these two memories must be remembered.

Note: The so-called read-only and random access refer to normal working conditions, that is, when the memory is used, not when the chip is manufactured. Otherwise, how does the data in the read-only memory come from? In fact, this principle is also easy to understand. Books cannot be changed after they are in our hands. When they are still raw materials - white paper, of course they can be printed by the printing factory.

By the way, let me explain a few other common concepts.

  PROM is called programmable memory. It is like our exercise books. When we buy them, they are blank and can be written on. But once written, they cannot be erased. So they can only be written once. If you write something wrong, it will be scrapped. (Now it has been eliminated)

  EPROM is called UV-erasable programmable read-only memory. After writing the contents, if you are not satisfied with them, you can use a special method to erase them and rewrite them. That is, use ultraviolet light to irradiate them. Ultraviolet light is like a "word eraser" that can erase the words and then rewrite them. Of course, if you erase them too many times, they will not work, so the number of times this chip can be erased is also limited - a few hundred times. (Now it has been eliminated)

   EEPROM, also called E2PROM, is called electrically erasable programmable read-only memory. It is similar to EEPROM in that what is written can also be erased and rewritten, but it is more convenient and does not require light. Data can be erased or rewritten using electricity, so it is much more convenient and has a long lifespan (ranging from tens of thousands to hundreds of thousands of times).

  FLASH, also known as flash memory, is an improved product of EEPROM. Its biggest feature is that it must be erased in blocks (the size of each block is not fixed, and products from different manufacturers have different specifications), while EEPROM can only erase one byte at a time. FLASH is now commonly used for large-capacity storage, such as USB flash drives.

  Once again, all the writing here does not refer to normal working conditions. Whether it is PROM or EPROM, their writing requires special conditions. Generally, we use a device called "programmer" to do this work. Once it is installed in its working position, it cannot be rewritten casually.

Keywords:MCU Reference address:MCU internal storage structure

Previous article:Analysis of the structure of single chip microcomputer parallel port
Next article:MCU system EMC test

Recommended ReadingLatest update time:2024-11-15 14:30

AVR microcontroller infrared remote control key value decoding experiment
AVR Learning Notes XVIII: Infrared Remote Control Key Value Decoding Experiment   18.1 Example Function  Infrared remote control is currently the most widely used means of communication and remote control. Since infrared remote control devices have the characteristics of small size, low power consumption, strong func
[Microcontroller]
AVR microcontroller infrared remote control key value decoding experiment
Study Notes: Learning MCU from Scratch (4) D/A Conversion
DAC0832 is a monolithic DC output 8-bit digital/analog converter made using CMOS technology. As shown in the figure, it consists of four parts: an inverted T-type R-2R resistor network, an analog switch, an operational amplifier, and a reference voltage VREF. The analog value V0 output by the operational amplifier is:
[Microcontroller]
Study Notes: Learning MCU from Scratch (4) D/A Conversion
Detailed analysis of the algorithm of single chip microcomputer digital filtering
 The main function of a single-chip microcomputer is to control peripheral devices and realize certain communications and data processing. However, in certain specific occasions, mathematical operations are inevitably used, although single-chip microcomputers are not good at implementing algorithms and performing comp
[Microcontroller]
Detailed analysis of the algorithm of single chip microcomputer digital filtering
Double breakthrough in high security and localization: Yuntu leads innovation in China's automotive MCU field
· Yuntu released the YTM32B1H series of high-end automotive-grade MCU chips, which feature high safety and stability and meet ASIL-D certification standards. · Yuntu's three product matrices of "general MCU/ZCU + dedicated SoC + high-performance processing chip HPU" cover 90% of applications in the five major areas
[Automotive Electronics]
Use Proteus to learn the serial port of 51 single chip microcomputer
I won't remember the theoretical knowledge of the serial port, there is a lot of it on the Internet. The serial port of the 51 microcontroller has 4 modes, namely mode 0, mode 1, mode 2, and mode 3. Because my purpose is to use the serial port mainly to communicate with the computer, so I mainly use mode 1 (in fact, I
[Microcontroller]
Use Proteus to learn the serial port of 51 single chip microcomputer
How to use the AVR microcontroller's integrated ADC to take analog readings from the surrounding environment
Schematic A Quick Review of ADCs Most people think that the analog world has lagged behind them, but the truth is that analog has never been stronger! With the rise of the Internet of Things and the production of sensors, billions of analog readings are being taken every second around the world. This is just one of
[Microcontroller]
How to use the AVR microcontroller's integrated ADC to take analog readings from the surrounding environment
51 single chip microcomputer project design: ultrasonic-based garage parking system and parking space detection
1. Design requirements: Original title of graduation project: This design is mainly used in indoor parking lots. It uses a 51 single-chip microcomputer or an embedded system, combined with an ultrasonic sensor, to detect whether there are vehicles parked in the parking space, and displays the parking space occupancy
[Microcontroller]
51 single chip microcomputer project design: ultrasonic-based garage parking system and parking space detection
Next Generation Automotive Microcontrollers
STMicroelectronics is committed to helping the automotive industry meet the challenges of electrification and digitalization. It not only provides the solutions needed at this stage, but also provides a more powerful unified MCU platform development strategy in the future, supporting the development of next-generati
[Automotive Electronics]
Latest Microcontroller Articles
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号