51 microcontroller stores programs and data

Publisher:SereneDreamerLatest update time:2024-03-19 Source: elecfans Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

Beginners always have this question. After downloading the program from the computer to the development board, where does the program go? In C51, where are users or applications, system programs and data stored?

From the physical structure, the 51 microcontroller can be divided into on-chip, off-chip program memory, and on-chip and off-chip data memory.


Functionally, the 51 microcontroller has program memory, on-chip data memory, special function registers, bit address space, and off-chip data memory.

program memory

The program memory of the 51 microcontroller is used to store codes and some fixed table constants.
The addressable program memory space is 64KB.

From a physical point of view, the 51 microcontroller can be divided into: on-chip and off-chip program memory. As an addressing space, the addressing rule is: first on-chip, then off-chip, on-chip and off-chip are continuous without overlap.
As shown in the figure: 51 microcontroller program memory addressing diagram.

 

51 microcontroller stores programs and data

 

How does the microcontroller execute instructions?
As shown in the figure:

 

51 microcontroller stores programs and data

Regardless of the on-chip program memory or the off-chip program memory, their addresses are shared. If there is 4K ROM on-chip, the address is 0x0000-0x0FFF, and 0x1000-0xFFFF is the address space of the external ROM. Whether this part of 0x0000-0x0FFF of the external ROM is used depends on the level value of the EA pin of the microcontroller. When EA=1, this part of the internal ROM is used, and this part of the external ROM is wasted; when EA=0, this part of the external ROM is used, and the internal ROM is wasted and unused. To read data from the CODE segment, you need to use the assembled MOVC instruction. The microcontroller will automatically determine from which memory the data is to be fetched based on the MOVC instruction, EA status, and the address value to be read.

The program address space can generally be arranged and used according to user needs, but for the entry address of a special program executed by the CPU, the user must store the corresponding program in accordance with regulations.
The special program entrance address is as shown in the figure:

 

51 microcontroller stores programs and data

 

data storage

The internal and external data memories of the 51 microcontroller are two independent address spaces and should be addressed separately.
On-chip data memory address space "00H-FFH", RAM address space "00H-7FH" special function register SFR address space "80H-FFH"
off-chip data memory address space "0000H-FFFFH"
as shown in the figure:

 

51 microcontroller stores programs and data

 

In order to make reasonable use of the storage space of the on-chip data memory, the lower 128 bytes of RAM are divided into different functional areas.
As shown in the picture:

51 microcontroller stores programs and data

 

51 microcontroller stores programs and data

Bit addressing area, address space 20H-2FH, 16 units, 128 bits in total.

Data buffer, address space 30H-7FH, 80 units in total.


Special function registers
Special function registers (SFR, Special Function Registers) are also called special-purpose registers. They are mainly used for management, control, on-chip logic components, parallel I/O ports, serial I/O ports, timers/counters, interrupt systems, etc. Functional modules work.

Summary: Data memory is divided into two parts: internal data memory (IDATA/RAM) and external data memory (XDATA), but these two memories do not share the address space like code memory. The general 8051 chip has only 128B of internal RAM, from 0x00-0x7F, and from 0x80-0xFF is the SFR area (the CPU working register and various peripheral registers are here). For 8052, the internal RAM is 256B, so 0x80-0xFF is the higher 128B of RAM in use. But isn’t this part exclusive to SFR? It is dedicated to SFR, but note that SFR can only be accessed using "direct addressing mode" (implemented using specific assembly instructions). This is the difference. Only addresses accessed via direct addressing are SFRs, otherwise it's ordinary RAM. As for the externally expanded RAM (XDATA), the address is also from 0x0000-0xFFFF, and the 0x0000 here is different from the 0x00 of the internal RAM. They are two completely independent spaces. Their access methods are also different. MCS-51 uses the MOVX instruction to read and write the XDATA area. Moreover, accessing the XDATA area requires the assistance of the DPTR register. Because only DPTR can hold the sixteen-digit XDATA address. refer to:

special function register

Special function registers (SFR, Special Function Registers), also known as special-purpose registers, are mainly used for management, control, on-chip logic components, parallel I/O ports, serial I/O ports, timers/counters, interrupt systems and other functional modules Work.

In the 51 microcontroller, the special registers and on-chip RAM are uniformly addressed and used as direct addressing.

The 51 microcontroller has 18 special registers, 3 of which are double-byte registers, occupying 21 bytes.

In the address space 80H-FFH of the SFR block, only 21 bytes are discretely distributed in the 128-byte range as special function registers. The remaining bytes are undefined, but users cannot perform "read and write operations" on these bytes. "

The following figure is a list of the names, indicators, and addresses of special function registers.

 

51 microcontroller stores programs and data


Reference address:51 microcontroller stores programs and data

Previous article:Perpetual calendar clock simulation design based on 51 microcontroller
Next article:51 microcontroller project template creation method

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号