"When introducing MCU resources earlier, we mentioned that STC89C52 has a total of 512 bytes of ram, which is used to save data. For example, the variables we define are directly stored in RAM. However, the 512 byte ram of MCU is not equal in status, but divided into blocks. There are differences in physical structure and usage between blocks. Therefore, we should also pay attention to some problems when using.
The ram of 51 single chip microcomputer is divided into two parts, one is on-chip RAM and the other is off-chip ram. The on-chip RAM address of standard 51 ranges from 0x00h to 0x7F, with a total of 128 bytes, while the 51 series microcontrollers we use now have extended on-chip RAM, that is, the ram ranges from 0x00 to 0xff, with a total of 256 bytes. The off chip RAM can be expanded to 0x0000 ~ 0xFFFF with a total of 64K bytes. Here's one thing you should understand. The addresses of on-chip RAM and off-chip RAM are not connected. The on-chip RAM starts from 0x00 and the off-chip ram starts from 0x0000. In addition, the terms on-chip and off chip come from the early 51 single chip microcomputer, which respectively refer to the inside and outside of the chip, but now almost all 51 single chip microcomputer chips are integrated with off chip ram, while the real off chip expansion is rarely used. Although it is also called off chip RAM, in fact, it is also inside the single chip microcomputer chip, This is our STC89C52. The following are some keywords in Keil C51 language, which represent the division of different regions of ram. Let's remember first.
Data: on chip ram from 0x00 to 0x7F
IData: on chip ram from 0x00 to 0xff
Pdata: off chip ram from 0x00 to 0xff
XDATA: off chip ram from 0x0000 to 0xFFFF
As you can see, data is a part of IData and pdata is a part of XDATA. Why do you distinguish like this? Because the access mode of ram blocks is mainly related to assembly instructions, you can understand this content. You only need to remember how to access faster.
We can define a variable a as follows: unsigned char data a = 0, but we didn't add the keyword data when we defined the variable, because data can be omitted under keil's default setting, that is, when nothing is added, the variable is defined in the data area. Data area RAM access is directly addressed in assembly language, and the execution speed is the fastest. If you define it as IData, you can access not only the data area, but also the range of 0x80h ~ 0xff. However, after adding the IData keyword, 51 MCU uses general register indirect addressing when accessing, which will be slower than data. Moreover, we don't want to access 0x80h ~ 0xff in most cases, Because this stack is usually used for interrupts and function calls, in most cases, when we use internal RAM, we can only use data.
For external RAM, the variables defined by pdata are stored in the address range of 0x00 ~ 0xff of external RAM. The access of this address is similar to IData, which is indirectly addressed by general registers. If you define XDATA, you can access a wider range, from 0 to 64K addresses, However, it needs to use two byte registers dptrh and dptrl for indirect addressing, and the speed is the slowest.
Our STC89C52 has 512 bytes of ram, which is divided into 256 bytes of on-chip RAM and 256 bytes of off chip ram. Generally, we use the data area. If data is not enough, we use XDATA. If we want the program execution efficiency to be as high as possible, we use the pdata keyword to define it. Other models of 51 Series MCU with larger ram must be accessed with XDATA if you want to use larger ram., Read the full text, technical section
How to add RDP function to STM32 single chip microcomputer
How to correctly divide the ram in 51 single chip microcomputer
How to solve the sensitivity problem of USB to serial port of single chip microcomputer
Design of intelligent temperature controller based on 51 single chip microcomputer
How to use STM32 MCU serial port to send string and download enthusiast app
Create an electronic circle of your contacts
Pay attention to wechat of electronic enthusiasts
Interesting and informative information and technology dry goods
Focus on enthusiast class
Lock in the latest course activities and technology live broadcast
Electronic enthusiast observation
Front line report, in-depth observation, latest information, collected
1 person collection
Share:, comment
Lin Chaowen PCB Design: pads tutorial, pads video tutorial, Zheng Zhenyu teacher: Altium designer tutorial, Altium designer video tutorial, Zhang Fei actual combat electronic video tutorial, Zhu Youpeng teacher: Hisilicon hi3518e tutorial, hi3518e video tutorial, Li Zeng teacher: signal integrity tutorial, high-speed circuit simulation tutorial, Huawei Hongmeng system tutorial, harmonyos video tutorial, saisheng: EMC design tutorial, EMC video tutorial Mr. Du Yang: STM32 tutorial, STM32 video tutorial, Tang zuolin: basic C language tutorial, basic C language video tutorial, Zhang Fei: Buck Power tutorial, buck power video tutorial, punctual atom: FPGA tutorial, FPGA video tutorial, Mr. Wei Dongshan: embedded tutorial, Embedded video tutorial Zhang Xianfeng: C language basic video tutorial Xu Xiaogang: Modbus communication video tutorial Wang Zhentao: NB IOT development video tutorial mill: FPGA tutorial, zynq video tutorial c language video tutorial linux driver development video tutorial Zhu Youpeng: u-boot source code analysis video tutorial harmonyos,
Press and hold the slider and drag to the far right
Learn about new features
Published, relevant recommendations
21479 ram test compilation overflow
Published at 09:56, December 11, 2018
•
7 readings
Design of intelligent temperature controller based on 51 single chip microcomputer
This is a 51 single chip microcomputer intelligent temperature controller C language source program, program function: quick clock display, using DS18B20 for temperature detection
Published at 16:07, December 10, 2018
•
49 readings
Design of infrared transmitting and receiving module circuit based on 51 single chip microcomputer
Infrared transmitting module: the power supply is 3.3V or 5V. It transmits 38kHz infrared signal through the transmitting tube and is driven at a high level
Infrared receiver module
Published at 15:49 on December 10, 2018
•
43 readings
Computer eye interface based on EZ-USB
Published at 10:19, December 10, 2018
•
24 readings
Detailed introduction of ten methods of PLC Analog input filtering
1. Limiting filtering method (also known as program judgment filtering method) A. method: according to empirical judgment, determine the maximum deviation allowed for two sampling (set as a) every
Published at 09:37, December 8, 2018
•
195 readings
Can communication design of 51 single chip microcomputer
//-----------------------Set the received message type (identifier) -------------
Published at 15:05, December 7, 2018
•
80 readings
When the DSP program code is copied from flash to ram, if I copy a function and call a sub function, will the sub function code be copied to ram
Published at 11:28, December 7, 2018
•
77 readings
What is the difference between ram and flash
Our other product: