The memory of the microcontroller is divided into two types: program memory ROM and data memory RAM. These two types of memory are strictly distinguished in use and cannot be mixed. The program memory stores program instructions, constants, tables, etc.; while the data memory stores buffer data.
The memory structure of MCS-51 microcontroller has three parts: one is program memory, the second is internal data memory, and the third is external data memory. The memory of MCS-51 microcontroller can be divided into five categories: program memory, internal data memory, special function registers, bit address space, and external data memory.
Program Memory
Programs are a series of commands that control the actions of a computer. The microcontroller only recognizes machine instructions consisting of "0" and "1" codes. For example, the command MOV A, #20H written in mnemonics is replaced by the machine-recognized code 74H, 20H: (written in binary, it is 01110100B and 00100000B). Before the microcontroller processes a problem, the compiled program, table, and constant must be compiled into machine code and stored in the microcontroller's memory, which is called program memory. The program memory can be placed inside or outside the chip, or it can be set inside and outside the chip at the same time. Since the PC program counter is 16 bits, the program memory can use a 16-bit binary address. Therefore, the maximum address of the internal and external memory can be from 0000H to FFFFH. 8051 has 4k bytes of ROM inside, which occupies the lowest 4k bytes from 0000H to 0FFFH. At this time, the address number of the program memory expanded outside the chip should start from 1000H. If 8051 is used as 8031, and you do not want to use the 4k ROM inside the chip, and use all the external memory, the address number can still start from 0000H. However, at this time, the {31}th pin (ie, EA pin) of 8051 should be kept at a low level. When EA is high, the user uses the internal ROM in the range of 0000H to 0FFFH. When it is greater than 0FFFH, the microcontroller CPU automatically accesses the external program memory.
Data storage
The data memory of the microcontroller is composed of read-write memory RAM. Its maximum capacity can be expanded to 64k, which is used to store real-time input data. There are 256 units of internal data memory in 8051, of which 00H~7FH is the internal random access memory RAM, and 80H~FFH is the special register area. In actual use, the internal memory should be fully utilized first. From the perspective of use, it is very important to understand the structure and address allocation of the internal data memory. Because they will be used frequently in the future when learning instruction systems and program design. The address of the internal data memory of 8051 is from 00H to FFH, with a total address space of 256 bytes. The space is divided into two parts, of which the address of the internal data RAM is 00H~7FH (that is, 0~127). The address used as a special function register is 80H~FFH. In these 256 bytes, there is also a so-called "bit address" area, which can be addressed not only by byte, but also by "bit". For those data that need to be operated on by bit, they can be stored in this area. There are four groups of working registers arranged from 00H to 1FH, each group occupies 8 RAM bytes, recorded as R0~R7. Which group of registers to use is selected by RS1 and RS0 in the above-mentioned flag register. Different binary numbers can be placed in these two bits to select different register groups.
Special Function Registers
The address range of the special function register (SFR) is 80H~FFH. In MCS-51, except for the program counter PC and four working register areas, the remaining 21 special function registers are all in this SFR block. Five of them are double-byte registers, which occupy a total of 26 bytes. The symbols and addresses of each special function register are shown in Appendix 2. Those with * are bit addressable. The special function register reflects the status of 8051, and is actually the status word and control word register of 8051. The CPU PSW is a typical example. These special function registers are generally divided into two categories, one is related to the pins of the chip, and the other is used for controlling the functions on the chip. The special function registers related to the chip pins are P0~P3, which are actually 4 eight-bit latches (one for each I/O port). Each latch is attached with a corresponding output driver and input buffer to form a parallel port. MCS-51 has four such parallel ports, P0~P3, which can provide 32 I/O lines, each of which is bidirectional and most of them have a second function. Among the other registers used for chip control, the functions of accumulator A, flag register PSW, data pointer DPTR, etc. have been mentioned before, and the functions of other registers will be further introduced in the relevant parts later.
Address Space
To ensure that multiple applications can be in memory at the same time and do not interfere with each other, two problems need to be solved: protection and relocation. Let's look at a primitive solution to the former, which was used on the IBM 360: mark memory blocks with a protection key, and compare the key of the executing process with the protection key of each memory word it accesses. However, this method itself does not solve the latter problem, although this problem can be solved by relocating the program when it is loaded, but this is a slow and complicated solution.
A better approach is to create a new memory abstraction: the address space. Just as the concept of a process creates an abstract CPU to run programs, the address space creates an abstract memory for programs. An address space is a set of addresses that a process can use to address memory. Each process has its own address space, and this address space is independent of the address space of other processes (except in some special cases where processes need to share their address space).
The concept of address space is very general and appears in many contexts. For example, in the United States and many other countries, a local telephone number is usually a 7-bit number. Therefore, the address space for telephone numbers is from 0 000 000 to 9 999 999, although some numbers are not used, such as those starting with 000. As the number of cell phones, modems, and fax machines increased, this space became less and less available, resulting in the need to use more digits. The address space of the Pentium's I/O ports is from 0 to 16 383. IPv4 addresses are 32-bit numbers, so their address space is from 0 to 232-1 (there are also some reserved numbers).
Address spaces do not have to be numeric. A set of ".com" Internet domain names is also an address space. This address space is made up of all strings of 2 to 63 characters followed by ".com". The characters that make up these strings can be letters, numbers, and hyphens. By now you should have understood the concept of address space. It is very simple.
External Memory
Floppy disks, hard disks, CDs, and USB flash drives are all external storage devices. From the working principle of von Neumann's stored program and the composition of computers, computers are divided into arithmetic units, controllers, storage devices, and input/output devices. The storage device here refers to the memory, and the hard disk belongs to the input/output device. The program code and data required for CPU calculations come from the memory, and the things in the memory come from the hard disk. Therefore, the hard disk does not deal directly with the CPU. The hard disk is an external storage device relative to the memory. The storage device is used to store data. The memory has cache and memory, which is the internal storage of the computer. The external storage device is an external storage device similar to the USB flash drive. The internal storage device is fast and expensive, and has a small capacity. The data in the memory will be lost after a power outage. The unit price of the external storage device is low, the capacity is large, the speed is slow, and the data will not be lost after a power outage.
Previous article:Addressing mode of microcontroller
Next article:Commonly used chips for single chip microcomputers
Recommended ReadingLatest update time:2024-11-17 00:29
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
- The startup method of high performance DSP in large capacity wireless transmission technology
- You may need oscilloscope information urgently, especially analog ones. You can get the information here.
- Share: Qinheng CH32V103 built-in Flash to extend the use time and balance wear and write
- XMC4800 Review (Part 2) - Unboxing and Lighting
- Create a child process instance
- Xunwei 3399 development board Linux firmware compilation-Ubuntu16 system compilation
- Share the use of Allegro Color command with everyone
- Comparison of technical indicators between N76E003AT20 and STM8S003F3P6
- 51 drives ST7920 to display custom size characters at any position. I don't know why it flashes when refreshing. Please guide me
- Guess the idiom