8051 MCU Basics 2: Core and Memory (RAM, Flash) Architecture

Publisher:科技先锋Latest update time:2021-12-01 Source: eefocus Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

References:

① Keil > Help

② "STC MCU Principles and Applications - Analysis and Design from Devices, Assembly, C to Operating Systems" by He Bin

③MCS-51 Series Microcontrollers and Their Applications (6th Edition) by Sun Yucai and Sun Huafang


The 8051 microcontroller architecture mainly includes:


CPU (computing unit, controller)

Memory (internal RAM, extended RAM, Flash)

Special Function Registers

Others: peripherals, clock system, etc.

insert image description here

Internal structure of the classic 8051 microcontroller

insert image description here

8051 memory structure and address space


1. CPU (Calculator, Controller)

The arithmetic unit and the controller make up the 8051 central processing unit (CPU).


1. Calculator

  The arithmetic unit of the microcontroller mainly includes 8-bit arithmetic/logic operation components, accumulator A, register B, program status register, etc. Its function is to realize data arithmetic/logic operations (data processing) and data transmission and other operations.


1) Arithmetic/Logic Unit ALU

  The core component of the arithmetic unit in the 8051 CPU is the arithmetic and logic unit (ALU), which is 8 bits wide. Its main function is to implement 8-bit addition, subtraction, multiplication and division operations, "and", "or", "exclusive or" logic operations, including bit operations and basic operations such as loop, clear "0", set "1", add "1", subtract "1", etc.


2) Accumulator ACC

  The accumulator (ACC) is a commonly used special register. The instruction system uses A as the mnemonic of the accumulator. It is often used to store operands and results of arithmetic or logical operations.


3) Register B

  Register B needs to be used together with ACC in multiplication and division operations. In other cases, register B can also be used as a general temporary register.


4) Program status word register PSW

  When the CPU performs arithmetic or logical operations on the Program Status Word (PSW), the corresponding PSW status bits will change.


2. Controller

1) Program Counter PC

  The Program Counter (PC) is used to store the address of the next instruction to be read from the program memory. It continuously reads instruction codes from the program memory, so that the computer can automatically and continuously execute instructions and run programs. The change of the content (address code) in the PC determines the direction of program operation.


  The width of the program counter is 16 bits, which determines the addressable range of the program memory of the microcontroller. That is, the maximum capacity of the addressable program memory is 64KB.


  The program counter cannot always increment the program address register because machine instructions can be divided into two situations: sequential execution and jump execution.


2) Command channel

a. Instruction fetch unit

  The instruction is fetched according to the address of the program memory pointed to by the PC. The machine instructions of 8051 are 8, 16 or 24 bits.


b. Decoding unit

  According to the opcode part of the instruction, it is converted into a series of logic control sequences, which will directly control the computing units within the CPU.


c. Execution instruction unit

  According to the logical behavior generated by the logic control sequence (microinstructions), the arithmetic unit is controlled to complete the operation behavior required by the instructions.


3) Dual data pointer DPTR

  The dual data pointer (DPTR) is a 16-bit dedicated register consisting of DPL and DPH. Its main function is to address the 16-bit address register of the external data memory, and can also address fixed data stored in the 64KB program memory.


4) Stack Pointer SP

  The Stack Pointer SP is an 8-bit special register that indicates the location of the top of the stack in the internal RAM block.


2. Memory (internal RAM, extended RAM, Flash)

  The 8051 architecture microcontroller memory mainly includes: internal RAM, extended RAM, special function registers and program memory Flash.


1. Internal RAM

  The internal RAM supports a maximum of 256 bytes of storage space; data can be read very quickly because it can be directly accessed through an 8-bit address;


  The lower 128 bytes can be directly addressed (data) or indirectly addressed (idata); the space from 20H to 2FH can be addressed by bit;


  The upper 128 bytes can only be addressed indirectly; when accessed directly, they are automatically mapped to the SFR space;


  The C51 compiler provides three different memory types to access internal RAM space: data, idata, and bdata;

image.png

2. Expand RAM

  When accessing the extended RAM area, indirect access is performed through a data pointer register, so the reading and writing speed is slower than the internal RAM area.


  The extended RAM area supports a maximum of 64K bytes of storage space, but these addresses are not necessarily all used for memory space. Some 8051 microcontrollers will map peripheral addresses to the extended RAM area.


  The C51 compiler provides two different memory types to access the extended RAM space: xdata and pdata:

image.png

3. Program memory Flash

  The 8051 architecture supports a maximum of 64K bytes of Flash space.


  Program code is stored in Flash space, and 8051 can only execute code stored in Flash. Constant variables can also be stored in Flash space.


  The way to access the Flash space is to use MOVC instruction for indirect addressing, not direct addressing;


3. Special Function Registers

  The 8051 architecture provides 128 bytes of memory space for special function registers (SFRs). SFRs and the upper 128 bytes of internal RAM share addresses 80H ~ FFH and can only be directly addressed.


  It is a collection of multiple control registers and status registers, which is used to manage, control and monitor various functional modules within the microcontroller.

Reference address:8051 MCU Basics 2: Core and Memory (RAM, Flash) Architecture

Previous article:Internal structure of MCS-51 single-chip microcomputer - CPU structure and single-chip microcomputer principle study notes (II)
Next article:8051 MCU Basics 5: Data Type Occupancy Size and Value Range

Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
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号