1. Memory overview
Memory is a collection of many storage units. The memory unit is actually a type of sequential logic circuit (latch), arranged in order of unit number. Each unit is composed of a number of binary bits to represent the value stored in the storage unit. This structure is very similar to the structure of an array. According to the type of memory usage, it can be divided into read-only memory (ROM) and random access memory (RAM).
1.1 Storage unit
Bit: It is the smallest unit of data in a computer. Since computers use binary numbers, a 1-bit binary number is called 1bit, for example, 101011 is 6bit.
Byte (unit abbreviated as B): 8-bit binary number is called a byte, 1B=8bit.
Word: Two bytes constitute a word, that is, 2Byte=1Word.
There is another commonly used term in microcontrollers: word length. The so-called word length refers to the number of binary digits that the microcontroller can process at one time. The 51 microcontroller can process 8-bit binary numbers at a time, so the word length of the 51 microcontroller is 8 bits.
1.2 Memory addressing
As shown in the figure below, a memory with a capacity of 256 bytes has 256 storage units inside. Each storage unit can store an 8-bit binary number. In order to facilitate data access, each storage unit needs to be numbered, that is, Memory unit addressing uses binary numbers. At least 8-bit binary numbers must be used to address all 256 memory units. The first memory unit is addressed as 00000000. For convenience when writing programs, hexadecimal is generally used. Number representation, the binary number 00000000 is expressed in hexadecimal as 00H, H represents a hexadecimal number, the second storage unit is addressed as 01H, and the 256th storage unit is addressed as FFH (can also be written as 0FFH).
Figure 1 Memory structure
1.3 Memory data reading and writing instructions
To read and write each storage unit of a 256-byte memory, 8 address lines and 8 data lines are required. First, an 8-bit address is sent to select a certain storage unit, and then according to read control or write control, the selected storage unit is The 8-bit data is sent out from the 8 data lines, or the 8-bit data is stored in the selected memory unit through the 8 data lines. Taking the memory structure in Figure 1 as an example, when the address bus A7~A0 sends the 8-bit address 00011111 (1FH) into the memory, the memory unit with the internal address 1FH will be selected, and then a read control will be sent from the read control line Signal, the data 00010111 in the 1FH storage unit is sent out from the 8 data buses D7~D0.
1.4 Memory address space description
MCS-51 microcontroller adopts Harvard structure, that is, the program space (ROM) and data space (RAM) are addressed separately. They have their own address spaces and do not overlap with each other, so ROM and RAM can have the same address code. In order to distinguish whether the variables at the same address are from ROM or RAM, any variable defined during programming must be located in a certain storage area of the MCS-51 microcontroller in a certain memory type. When programming with C51, you only need to use keywords to define the memory type of variables. The memory types of C51 variables are shown in the table below.
From the perspective of physical address space, the memory of MCS-51 microcontroller has 4 address spaces, which are 4KB on-chip ROM, 64KB off-chip ROM, 256B on-chip RAM, and 64KB off-chip RAM.
2.ROM (program memory)
ROM (Program Memory) stores programs, tables and constants that must always be retained, equivalent to the hard disk of a computer system;
2.1 Internal and external ROM (program memory)
The 8051 microcontroller has an internal 4KB program memory. If the internal program memory is not enough (or there is no internal program memory), an external program memory can be connected. The 8051 microcontroller can be connected to a program memory (ROM) with a maximum capacity of 64KB, which is uniformly addressed with the on-chip 4KB program memory.
When a microcontroller
When the terminal is connected to high level (connected to the positive pole of the power supply), both on-chip and off-chip program memory can be used. The on-chip 4KB program memory is addressed from 0000H to 0FFFH, and the off-chip 64KB program memory is addressed from 1000H to FFFFH. The lower 4KB storage space of external program memory cannot be used, as shown in the figure below.
When a microcontroller
When the terminal is connected to low level (grounded), only the off-chip program memory can be used, and its address is 0000H~FFFFH. The on-chip 4KB program memory cannot be used, as shown in the figure below.
2.2 Description of on-chip and on-chip ROM (program memory)
(1) Whether using on-chip ROM or off-chip ROM, the starting address of the program starts from unit 0000H of the ROM.
(2) Although the microcontroller can have both internal and external ROM, under normal circumstances, both need to pass
settings to choose one.
(3) If
=1, when the program exceeds the on-chip ROM capacity (4KB: 0000H~0FFFH), the microcontroller will automatically turn to the off-chip ROM and start executing the program from unit 1000H (the lower 4KB space of the off-chip ROM cannot be used). At present, the on-chip ROM capacity of general microcontrollers is sufficient, so there is little or no need to expand the off-chip ROM.
The ROM space can generally be used arbitrarily according to user needs, but some addresses in the ROM are occupied by the entry addresses of interrupt programs, as shown in the table below.
Copyright statement: This article is an original article by CSDN blogger "Hudou24" and follows the CC 4.0 BY-SA copyright agreement. Please attach the original source link and this statement when reprinting. The copyright belongs to the original author. If there is any infringement, please contact us to delete it.
Previous article:51 microcontroller learning-button control LED
Next article:51 microcontroller - memory (2)
Recommended ReadingLatest update time:2024-11-16 10:24
- Popular Resources
- Popular amplifiers
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
- IoT architecture and technology protocols
- Review Weekly Report 20221010: Sipeed GW2A FPGA development board and Renesas ultra-low power MCU RA2L1 are here~
- Why can a Zener diode break down with a reverse current of just a few volts, but a rectifier diode cannot break down with a reverse current of more than 200 volts?
- Semiconductor Recruitment-Shanghai, Shenzhen, Hangzhou
- Things to note when configuring 4G router ports
- Four major reasons for the heating of power modules
- [Erha Image Recognition Artificial Intelligence Vision Sensor] 3. Serial communication with the processor
- (Paid Purchase) SSRP-7.25 Motherboard PCB
- LCR parallel resonance
- How to implement the 0-10V circuit of the inverter and motor speed control interface?