HOME

TheInfoList



OR:

The Intel MCS-51 (commonly termed 8051) is a single chip
microcontroller A microcontroller (MCU for ''microcontroller unit'', often also MC, UC, or μC) is a small computer on a single VLSI integrated circuit (IC) chip. A microcontroller contains one or more CPUs (processor cores) along with memory and programmable i ...
(MCU) series developed by
Intel Intel Corporation is an American multinational corporation and technology company headquartered in Santa Clara, California. It is the world's largest semiconductor chip manufacturer by revenue, and is one of the developers of the x86 seri ...
in 1980 for use in
embedded system An embedded system is a computer system—a combination of a computer processor, computer memory, and input/output peripheral devices—that has a dedicated function within a larger mechanical or electronic system. It is ''embedded'' as ...
s. The architect of the Intel MCS-51 instruction set was John H. Wharton. Intel's original versions were popular in the 1980s and early 1990s, and enhanced
binary compatible Binary-code compatibility (binary compatible or object-code-compatible) is a property of a computer system, meaning that it can run the same executable code, typically machine code for a general-purpose computer CPU, that another computer syst ...
derivatives remain popular today. It is an example of a
complex instruction set computer A complex instruction set computer (CISC ) is a computer architecture in which single instructions can execute several low-level operations (such as a load from memory, an arithmetic operation, and a memory store) or are capable of multi-step ...
(but also possessing some of the features of
RISC In computer engineering, a reduced instruction set computer (RISC) is a computer designed to simplify the individual instructions given to the computer to accomplish tasks. Compared to the instructions given to a complex instruction set comput ...
architectures, such as a large register set and
register window In computer engineering, register windows are a feature which dedicates registers to a subroutine by dynamically aliasing a subset of internal registers to fixed, programmer-visible registers. Register windows are implemented to improve the perf ...
s) and has separate memory spaces for program instructions and data. Intel's original MCS-51 family was developed using N-type metal-oxide-semiconductor ( NMOS) technology, like its predecessor Intel MCS-48, but later versions, identified by a letter C in their name (e.g., 80C51) use complementary metal–oxide–semiconductor (
CMOS Complementary metal–oxide–semiconductor (CMOS, pronounced "sea-moss", ) is a type of metal–oxide–semiconductor field-effect transistor (MOSFET) fabrication process that uses complementary and symmetrical pairs of p-type and n-type MOSFE ...
) technology and consume less power than their NMOS predecessors. This made them more suitable for battery-powered devices. The family was continued in 1996 with the enhanced
8-bit In computer architecture, 8-bit Integer (computer science), integers or other Data (computing), data units are those that are 8 bits wide (1 octet (computing), octet). Also, 8-bit central processing unit (CPU) and arithmetic logic unit (ALU) arc ...
MCS-151 and the 8/
16-bit 16-bit microcomputers are microcomputers that use 16-bit microprocessors. A 16-bit register can store 216 different values. The range of integer values that can be stored in 16 bits depends on the integer representation used. With the two mos ...
/
32-bit In computer architecture, 32-bit computing refers to computer systems with a processor, memory, and other major system components that operate on data in 32-bit units. Compared to smaller bit widths, 32-bit computers can perform large calculation ...
MCS-251 family of binary compatible microcontrollers. While Intel no longer manufactures the MCS-51, MCS-151 and MCS-251 family, enhanced
binary compatible Binary-code compatibility (binary compatible or object-code-compatible) is a property of a computer system, meaning that it can run the same executable code, typically machine code for a general-purpose computer CPU, that another computer syst ...
derivatives made by numerous vendors remain popular today. Some derivatives integrate a
digital signal processor A digital signal processor (DSP) is a specialized microprocessor chip, with its architecture optimized for the operational needs of digital signal processing. DSPs are fabricated on MOS integrated circuit chips. They are widely used in audio si ...
(DSP) or a
floating point unit Floating may refer to: * a type of dental work performed on horse teeth * use of an isolation tank * the guitar-playing technique where chords are sustained rather than scratched * ''Floating'' (play), by Hugh Hughes * Floating (psychological phe ...
(coprocessor, FPU). Beyond these physical devices, several companies also offer MCS-51 derivatives as
IP core In electronic design, a semiconductor intellectual property core (SIP core), IP core, or IP block is a reusable unit of logic, cell, or integrated circuit layout design that is the intellectual property of one party. IP cores can be licensed to ...
s for use in
field-programmable gate array A field-programmable gate array (FPGA) is an integrated circuit designed to be configured by a customer or a designer after manufacturinghence the term '' field-programmable''. The FPGA configuration is generally specified using a hardware d ...
(FPGA) or
application-specific integrated circuit An application-specific integrated circuit (ASIC ) is an integrated circuit (IC) chip customized for a particular use, rather than intended for general-purpose use, such as a chip designed to run in a digital voice recorder or a high-efficie ...
(ASIC) designs.


Important features and applications

The 8051 architecture provides many functions (
central processing unit A central processing unit (CPU), also called a central processor, main processor or just processor, is the electronic circuitry that executes instructions comprising a computer program. The CPU performs basic arithmetic, logic, controlling, an ...
(CPU),
random-access memory Random-access memory (RAM; ) is a form of computer memory that can be read and changed in any order, typically used to store working Data (computing), data and machine code. A Random access, random-access memory device allows data items to b ...
(RAM),
read-only memory Read-only memory (ROM) is a type of non-volatile memory used in computers and other electronic devices. Data stored in ROM cannot be electronically modified after the manufacture of the memory device. Read-only memory is useful for storing sof ...
(ROM),
input/output In computing, input/output (I/O, or informally io or IO) is the communication between an information processing system, such as a computer, and the outside world, possibly a human or another information processing system. Inputs are the signals ...
(I/O) ports, serial port,
interrupt In digital computers, an interrupt (sometimes referred to as a trap) is a request for the processor to ''interrupt'' currently executing code (when permitted), so that the event can be processed in a timely manner. If the request is accepted, ...
control,
timer A timer is a specialized type of clock used for measuring specific time intervals. Timers can be categorized into two main types. The word "timer" is usually reserved for devices that counts down from a specified time interval, while devices th ...
s) in one package: * 8-
bit The bit is the most basic unit of information in computing and digital communications. The name is a portmanteau of binary digit. The bit represents a logical state with one of two possible values. These values are most commonly represente ...
arithmetic logic unit In computing, an arithmetic logic unit (ALU) is a Combinational logic, combinational digital circuit that performs arithmetic and bitwise operations on integer binary numbers. This is in contrast to a floating-point unit (FPU), which operates on ...
(ALU) and accumulator, 8-bit registers (one
16-bit 16-bit microcomputers are microcomputers that use 16-bit microprocessors. A 16-bit register can store 216 different values. The range of integer values that can be stored in 16 bits depends on the integer representation used. With the two mos ...
register with special move instructions), 8-bit
data bus In computer architecture, a bus (shortened form of the Latin '' omnibus'', and historically also called data highway or databus) is a communication system that transfers data between components inside a computer, or between computers. This ex ...
and 2×16-bit
address bus In computer architecture, a bus (shortened form of the Latin '' omnibus'', and historically also called data highway or databus) is a communication system that transfers data between components inside a computer, or between computers. This ex ...
es,
program counter The program counter (PC), commonly called the instruction pointer (IP) in Intel x86 and Itanium microprocessors, and sometimes called the instruction address register (IAR), the instruction counter, or just part of the instruction sequencer, is ...
,
data pointer In computer science, a pointer is an object in many programming languages that stores a memory address. This can be that of another value located in computer memory, or in some cases, that of memory-mapped computer hardware. A pointer ''refe ...
, and related 8/11/16-bit operations; hence it is mainly an
8-bit In computer architecture, 8-bit Integer (computer science), integers or other Data (computing), data units are those that are 8 bits wide (1 octet (computing), octet). Also, 8-bit central processing unit (CPU) and arithmetic logic unit (ALU) arc ...
microcontroller A microcontroller (MCU for ''microcontroller unit'', often also MC, UC, or μC) is a small computer on a single VLSI integrated circuit (IC) chip. A microcontroller contains one or more CPUs (processor cores) along with memory and programmable i ...
* Boolean processor with 17 instructions, 1-bit accumulator, 32 registers (4x8-bit, bit-addressable) and up to 144 special 1 bit-addressable RAM variables (18x8-bit) *
Multiply Multiplication (often denoted by the cross symbol , by the mid-line dot operator , by juxtaposition, or, on computers, by an asterisk ) is one of the four elementary mathematical operations of arithmetic, with the other ones being additi ...
, divide and
compare Comparison or comparing is the act of evaluating two or more things by determining the relevant, comparable characteristics of each thing, and then determining which characteristics of each are similar to the other, which are different, and t ...
instructions * Four fast switchable register banks with eight registers each (
memory map In computer science, a memory map is a structure of data (which usually resides in memory itself) that indicates how memory is laid out. The term "memory map" can have different meanings in different contexts. *It is the fastest and most flexible ...
ped) * Fast interrupt with optional register bank switching *
Interrupt In digital computers, an interrupt (sometimes referred to as a trap) is a request for the processor to ''interrupt'' currently executing code (when permitted), so that the event can be processed in a timely manner. If the request is accepted, ...
s and threads with selectable priority * 128 or 256
byte The byte is a unit of digital information that most commonly consists of eight bits. Historically, the byte was the number of bits used to encode a single character of text in a computer and for this reason it is the smallest addressable unit ...
s of on-chip RAM (IRAM) * Dual 16-bit
address bus In computer architecture, a bus (shortened form of the Latin '' omnibus'', and historically also called data highway or databus) is a communication system that transfers data between components inside a computer, or between computers. This ex ...
; it can access 2×216 memory locations: 64  KB (65,536 locations) each of ROM (PMEM) and external RAM (XRAM), using two memory buses in a
Harvard architecture The Harvard architecture is a computer architecture with separate storage and signal pathways for instructions and data. It contrasts with the von Neumann architecture, where program instructions and data share the same memory and pathways. ...
. * On-chip ROM (not included on 803x variants) * Four (three full) 8-
bit The bit is the most basic unit of information in computing and digital communications. The name is a portmanteau of binary digit. The bit represents a logical state with one of two possible values. These values are most commonly represente ...
bi-directional
input/output In computing, input/output (I/O, or informally io or IO) is the communication between an information processing system, such as a computer, and the outside world, possibly a human or another information processing system. Inputs are the signals ...
ports, bit addressable * UART (
serial port In computing, a serial port is a serial communication interface through which information transfers in or out sequentially one bit at a time. This is in contrast to a parallel port, which communicates multiple bits simultaneously in parallel. ...
) * Two 16-bit counter/
timer A timer is a specialized type of clock used for measuring specific time intervals. Timers can be categorized into two main types. The word "timer" is usually reserved for devices that counts down from a specified time interval, while devices th ...
s *
Power saving Energy conservation is the effort to reduce wasteful energy consumption by using fewer energy services. This can be done by using energy more effectively (using less energy for continuous service) or changing one's behavior to use less service (f ...
mode (on some derivatives) One feature of the 8051 core is the inclusion of a boolean processing engine, which allows
bit The bit is the most basic unit of information in computing and digital communications. The name is a portmanteau of binary digit. The bit represents a logical state with one of two possible values. These values are most commonly represente ...
-level
boolean logic In mathematics and mathematical logic, Boolean algebra is a branch of algebra. It differs from elementary algebra in two ways. First, the values of the variable (mathematics), variables are the truth values ''true'' and ''false'', usually denote ...
operations to be carried out directly and efficiently on select internal
register Register or registration may refer to: Arts entertainment, and media Music * Register (music), the relative "height" or range of a note, melody, part, instrument, etc. * ''Register'', a 2017 album by Travis Miller * Registration (organ), th ...
s, ports and select
RAM Ram, ram, or RAM may refer to: Animals * A male sheep * Ram cichlid, a freshwater tropical fish People * Ram (given name) * Ram (surname) * Ram (director) (Ramsubramaniam), an Indian Tamil film director * RAM (musician) (born 1974), Dutch * ...
locations. Another feature is the inclusion of four bank selectable working register sets, which greatly reduce the time required to perform the
context switch In computing, a context switch is the process of storing the state of a process or thread, so that it can be restored and resume execution at a later point, and then restoring a different, previously saved, state. This allows multiple processes ...
es to enter and leave
interrupt service routine In computer systems programming, an interrupt handler, also known as an interrupt service routine or ISR, is a special block of code associated with a specific interrupt condition. Interrupt handlers are initiated by hardware interrupts, softwar ...
s. With one instruction, the 8051 can switch register banks, avoiding the time-consuming task of transferring the critical registers to RAM. Once a UART, and a timer if necessary, has been configured, the programmer needs only write a simple interrupt routine to refill the ''send'' shift register whenever the last bit is shifted out by the UART and/or empty the full ''receive'' shift register (copy the data somewhere else). The main program then performs serial reads and writes simply by reading and writing 8-bit data to stacks.


Derivative features

, new derivatives are still being developed by many major chipmakers, and major compiler suppliers such as
IAR Systems IAR Systems is a Swedish computer software company that offers development tools for embedded systems. IAR Systems was founded in 1983, and is listed on Nasdaq Nordic in Stockholm. IAR is an abbreviation of Ingenjörsfirma Anders Rundgren, which ...
, Keil and Altium Tasking continuously release updates. MCS-51 based microcontrollers typically include one or two
UART A universal asynchronous receiver-transmitter (UART ) is a computer hardware device for asynchronous serial communication in which the data format and transmission speeds are configurable. It sends data bits one by one, from the least significan ...
s, two or three timers, 128 or 256 bytes of internal data
RAM Ram, ram, or RAM may refer to: Animals * A male sheep * Ram cichlid, a freshwater tropical fish People * Ram (given name) * Ram (surname) * Ram (director) (Ramsubramaniam), an Indian Tamil film director * RAM (musician) (born 1974), Dutch * ...
(16 bytes of which are bit-addressable), up to 128 bytes of I/O, 512 bytes to 64 KB of internal program memory, and sometimes a quantity of extended data RAM (ERAM) located in the external data space. External RAM and ROM share the data and address buses. The original 8051 core ran at 12 clock cycles per machine cycle, with most instructions executing in one or two machine cycles. With a 12 MHz
clock frequency In computing, the clock rate or clock speed typically refers to the frequency at which the clock generator of a processor can generate pulses, which are used to synchronize the operations of its components, and is used as an indicator of the pr ...
, the 8051 could thus execute 1 million one-cycle instructions per second or 500,000 two-cycle instructions per second. Enhanced 8051 cores are now commonly used which run at six, four, two, or even one clock per machine cycle (denoted "1T"), and have clock frequencies of up to 100 MHz, and are thus capable of an even greater number of instructions per second. All
Silicon Labs Silicon Laboratories, Inc. (Silicon Labs) is a fabless global technology company that designs and manufactures semiconductors, other silicon devices and software, which it sells to electronics design engineers and manufacturers in Internet of Th ...
, some
Dallas Dallas () is the List of municipalities in Texas, third largest city in Texas and the largest city in the Dallas–Fort Worth metroplex, the List of metropolitan statistical areas, fourth-largest metropolitan area in the United States at 7.5 ...
(now part of
Maxim Integrated Maxim Integrated, a subsidiary of Analog Devices, designs, manufactures, and sells analog and mixed-signal integrated circuits for the automotive, industrial, communications, consumer, and computing markets. Maxim's product portfolio includes p ...
) and a few
Atmel Atmel Corporation was a creator and manufacturer of semiconductors before being subsumed by Microchip Technology in 2016. Atmel was founded in 1984. The company focused on embedded systems built around microcontrollers. Its products included micr ...
(now part of
Microchip An integrated circuit or monolithic integrated circuit (also referred to as an IC, a chip, or a microchip) is a set of electronic circuits on one small flat piece (or "chip") of semiconductor material, usually silicon. Large numbers of tiny M ...
) devices have single cycle cores. 8051 variants may include built-in reset timers with brown-out detection, on-chip oscillators, self-programmable
flash ROM Flash memory is an electronic non-volatile computer memory storage medium that can be electrically erased and reprogrammed. The two main types of flash memory, NOR flash and NAND flash, are named for the NOR and NAND logic gates. Both use ...
program memory, built-in external RAM, extra internal program storage,
bootloader A bootloader, also spelled as boot loader or called boot manager and bootstrap loader, is a computer program that is responsible for booting a computer. When a computer is turned off, its softwareincluding operating systems, application code, an ...
code in ROM,
EEPROM EEPROM (also called E2PROM) stands for electrically erasable programmable read-only memory and is a type of non-volatile memory used in computers, usually integrated in microcontrollers such as smart cards and remote keyless systems, or as a ...
non-volatile data storage, I2C, SPI, and
USB Universal Serial Bus (USB) is an industry standard that establishes specifications for cables, connectors and protocols for connection, communication and power supply (interfacing) between computers, peripherals and other computers. A broad ...
host interfaces,
CAN Can may refer to: Containers * Aluminum can * Drink can * Oil can * Steel and tin cans * Trash can * Petrol can * Metal can (disambiguation) Music * Can (band), West Germany, 1968 ** ''Can'' (album), 1979 * Can (South Korean band) Other * C ...
or
LIN Lin or LIN may refer to: People *Lin (surname) (normally ), a Chinese surname *Lin (surname) (normally 蔺), a Chinese surname * Lin (''The King of Fighters''), Chinese assassin character *Lin Chow Bang, character in Fat Pizza Places *Lin, Iran, ...
bus,
ZigBee Zigbee is an IEEE 802.15.4-based specification for a suite of high-level communication protocols used to create personal area networks with small, low-power digital radios, such as for home automation, medical device data collection, and othe ...
or
Bluetooth Bluetooth is a short-range wireless technology standard that is used for exchanging data between fixed and mobile devices over short distances and building personal area networks (PANs). In the most widely used mode, transmission power is limi ...
radio modules, PWM generators, analog
comparator In electronics, a comparator is a device that compares two voltages or currents and outputs a digital signal indicating which is larger. It has two analog input terminals V_+ and V_- and one binary digital output V_\text. The output is ideally : ...
s,
analog-to-digital In electronics, an analog-to-digital converter (ADC, A/D, or A-to-D) is a system that converts an analog signal, such as a sound picked up by a microphone or light entering a digital camera, into a digital signal. An ADC may also provide ...
and
digital-to-analog converter In electronics, a digital-to-analog converter (DAC, D/A, D2A, or D-to-A) is a system that converts a digital signal into an analog signal. An analog-to-digital converter (ADC) performs the reverse function. There are several DAC architec ...
s, RTCs, extra counters and timers, in-circuit
debugging In computer programming and software development, debugging is the process of finding and resolving '' bugs'' (defects or problems that prevent correct operation) within computer programs, software, or systems. Debugging tactics can involve in ...
facilities, more interrupt sources, extra power saving modes, more/less parallel ports etc. Intel manufactured a mask programmed version, 8052AH-BASIC, with a
BASIC BASIC (Beginners' All-purpose Symbolic Instruction Code) is a family of general-purpose, high-level programming languages designed for ease of use. The original version was created by John G. Kemeny and Thomas E. Kurtz at Dartmouth College ...
interpreter in ROM, capable of running user programs loaded into RAM. MCS-51 based microcontrollers have been adapted to extreme environments. Examples for high-temperature variants are the Tekmos TK8H51 family for −40°C to +250°C or the
Honeywell Honeywell International Inc. is an American publicly traded, multinational conglomerate corporation headquartered in Charlotte, North Carolina. It primarily operates in four areas of business: aerospace, building technologies, performance ma ...
HT83C51 for −55°C to +225°C (with operation for up to 1 year at +300°C). Radiation-hardenend MCS-51 microcontrollers for use in spacecraft are available; e.g., from Cobham (formerly
Aeroflex Aeroflex Inc. was an American company which produced test equipment, RF and microwave integrated circuits, components and systems used for wireless communications. Its headquarters were located in Plainview, New York. In May 2014, Aeroflex was ...
) as the UT69RH051 or from NIIET as the 1830VE32 (russian: 1830ВЕ32). In some engineering schools, the 8051 microcontroller is used in introductory microcontroller courses.


Family naming conventions

8051 is the original name by Intel with 4 KB ROM and 128 byte RAM. Variants starting with 87 have a user programmable EPROM, sometimes UV erasable. Variants with a C as the third character are some kind of
CMOS Complementary metal–oxide–semiconductor (CMOS, pronounced "sea-moss", ) is a type of metal–oxide–semiconductor field-effect transistor (MOSFET) fabrication process that uses complementary and symmetrical pairs of p-type and n-type MOSFE ...
. 8031 and 8032 are ROM-less versions, with 128 and 256 bytes RAM. The last digit can indicate memory size, e.g. 8052 with 8 KB ROM, 87C54 16 KB EPROM, and 87C58 with 32 KB EPROM, all with 256 byte RAM.


Memory architecture

The MCS-51 has four distinct types of memory: internal RAM, special function registers, program memory, and external data memory. To access these efficiently, some compilers utilize as many as 7 types of memory definitions: Internal RAM, single-bit access to internal RAM, special function registers, single-bit access to selected (divisible by 8) special function registers, program RAM, external ram accessed using a register indirect access, using one of the standard 8-bit registers, and register indirect external RAM access utilizing the 16-bit indirect access register. The 8051's instruction set is designed as a
Harvard architecture The Harvard architecture is a computer architecture with separate storage and signal pathways for instructions and data. It contrasts with the von Neumann architecture, where program instructions and data share the same memory and pathways. ...
with segregated memory (data and instructions); it can only execute code fetched from program memory, and has no instructions to write to program memory. However, the bus leaving the IC has a single address and data path, and strongly resembles a
Von Neumann architecture The von Neumann architecture — also known as the von Neumann model or Princeton architecture — is a computer architecture based on a 1945 description by John von Neumann, and by others, in the ''First Draft of a Report on the EDVAC''. The ...
bus. Most 8051 systems respect the instruction set, and require customized features to download new executable programs, e.g. in flash memory.


Internal RAM

Internal RAM (IRAM) has an 8-bit address space, using addresses 0 through 0xFF. IRAM from 0x00 to 0x7F contains 128 directly addressable 1-byte registers, which can be accessed using an 8-bit absolute address that is part of the instruction. Alternatively, IRAM can be accessed indirectly: the address is loaded into R0 or R1, and the memory is accessed using the @R0 or @R1 syntax, or as stack memory through the stack pointer SP, with the PUSH and POP operations; and *CALL and RET operations. The original 8051 has only 128 bytes of IRAM. The 8052 added IRAM from 0x80 to 0xFF, which can ''only'' be accessed indirectly (e.g. for use as stack space). Most 8051 clones also have a full 256 bytes of IRAM. Direct accesses to the IRAM addresses 80-FF are, instead, mapped onto the special function registers (SFR), where the accumulators A, B, carry bit C, and other special registers for control, status, etc., are located.


Special function registers

Special function registers (SFR) are located in the same address space as IRAM, at addresses 0x80 to 0xFF, and are accessed directly using the same instructions as for the lower half of IRAM. They cannot be accessed indirectly via @R0 or @R1 or by the stack pointer SP; indirect access to those addresses will access the second half of IRAM, instead. The special function registers (SFR) include the accumulators A (or ACC, at E0) and B (at F0) and program status word (or PSW, at D0), themselves, as well as the 16-bit data pointer DPTR (at 82, as DPL and 83 as DPH). In addition to these, a small core of other special function registers - including the interrupt enable IE at A8 and interrupt priority IP at B8; the I/O ports P0 (80), P1 (90), P2 (A0), P3 (B0); the serial I/O control SCON (98) and buffer SBUF (99); the CPU/power control register PCON (87); and the registers for timers 0 and 1 control (TCON at 88) and operation mode (TMOD at 89), the 16-bit timer 0 (TL0 at 8A, TH0 at 8C) and timer 1 (TL1 at 8B, TH1 at 8D) - are present on all versions of the 8051. Other addresses are version-dependent; in particular, the timer 2 registers for the 8052: the control register T2CON (at C8), the 16-bit capture/latch (RCAP2L at CA, RCAP2H at CB) and timer 2 (TL2 at CC and TH2 at CD), are not included with the 8051.


Register windows

The 32 bytes in IRAM from 0x00–0x1F contains space for four eight-byte
register window In computer engineering, register windows are a feature which dedicates registers to a subroutine by dynamically aliasing a subset of internal registers to fixed, programmer-visible registers. Register windows are implemented to improve the perf ...
s, which the 8 registers R0–R7 map to. The currently active window is determined by a two-bit address contained in the program status word.


Bit registers

The 16 bytes (128 bits) at IRAM locations 0x20–0x2F contains space for 128 1-bit registers, which are separately addressable as bit registers 00-7F. The remaining bit registers, addressed as 80-FF, are mapped onto the 16 special function registers 80, 88, 90, 98, ..., F0 and F8 (those whose addresses are multiples of 8), and therefore include the bits comprising the accumulators A, B and program status word PSW. The register window address, being bits 3 and 4 on PSW, is itself addressable as bit registers D3 and D4, respectively; while the carry bit C (or CY), at bit 7 of the PSW, is addressable as bit register D7.


Program memory

Program memory (PMEM, though less common in usage than IRAM and XRAM) is up to 64 KB of read-only memory, starting at address 0 in a separate address space. It may be on- or off-chip, depending on the particular model of chip being used. Program memory is read-only, though some variants of the 8051 use on-chip flash memory and provide a method of re-programming the memory in-system or in-application. In addition to code, it is possible to store read-only data such as
lookup table In computer science, a lookup table (LUT) is an array that replaces runtime computation with a simpler array indexing operation. The process is termed as "direct addressing" and LUTs differ from hash tables in a way that, to retrieve a value v wi ...
s in program memory, retrieved by the or instructions. The address is computed as the sum of the 8-bit accumulator and a 16-bit register (PC or DPTR). Special jump and call instructions ( and ) slightly reduce the size of code that accesses local (within the same 2 KB) program memory. When code larger than 64K is required, a common system makes the code bank-switched, with general-purpose I/O selecting the upper address bits. Some 8051 compilers make provisions to automatically access paged code. In these systems the interrupt vectors and paging table are placed in the first 32K of code, and are always resident.


External data memory

External data memory (XRAM) is a third address space, also starting at address 0, and allowing 16 bits of address space. It can also be on- or off-chip; what makes it "external" is that it must be accessed using the (move external) instruction. Many variants of the 8051 include the standard 256 bytes of IRAM plus a few kilobytes of XRAM on the chip. The first 256 bytes of XRAM may be accessed using the , , , and instructions. The full 64KB may be accessed using and . The 16-bit address requires the programmer to load the 16-bit index register. For this reason, RAM accesses with 16-bit addresses are substantially slower. Some CPUs permit the 8-bit indirect address to use any 8-bit general purpose register. To permit the use of this feature, some 8051-compatible microcontrollers with internal RAM larger than 256 bytes, or an inability to access external RAM access internal RAM as if it were external, and have a special function register (e.g. PDATA) that permits them to set the upper address of the 256-byte page. This emulates the MCS8051 mode that can page the upper byte of a RAM address by setting the general-purpose I/O pins. When RAM larger than 64K is required, a common system makes the RAM bank-switched, with general-purpose I/O selecting the upper address bits. Some 8051 compilers make provisions to automatically access paged data.


Registers

The only register on an 8051 that is not memory-mapped is the 16-bit program counter (PC). This specifies the address of the next instruction to execute. Relative branch instructions supply an 8-bit signed offset which is added to the PC. Eight general-purpose registers R0–R7 may be accessed with instructions one byte shorter than others. They are mapped to IRAM between 0x00 and 0x1F. Only eight bytes of that range are used at any given time, determined by the two bank select bits in the PSW. The following is a partial list of the 8051's registers, which are memory-mapped into the special function register space: ; Stack pointer, SP (0x81): This is an 8-bit register used by subroutine call and return instructions. The stack grows upward; the SP is incremented before pushing, and decremented after popping a value. ; Data pointer, DP (0x82–83): This is a 16-bit register that is used for accessing PMEM and XRAM. ; Program status word, PSW (0xD0): This contains important status flags, by bit number: ; Accumulator, A (0xE0): This register is used by most instructions. ; B register (0xF0): This is used as an extension to the accumulator for multiply and divide instructions. 256 single bits are directly addressable. These are the 16 IRAM locations from 0x20–0x2F, and the 16 special function registers 0x80, 0x88, 0x90, ..., 0xF8. Any bit of these bytes may be directly accessed by a variety of logical operations and conditional branches. Note that the PSW does not contain the common negative (N), or zero (Z) flags. For the former, the most significant bit of the accumulator can be addressed directly, as it is a bit-addressable SFR. For the latter, there are explicit instructions to jump on whether or not the accumulator is zero. There is also a two-operand compare and jump operation. The parity (P) bit is often used to implement serial modes that include parity. To support this, the standard MCS51
UART A universal asynchronous receiver-transmitter (UART ) is a computer hardware device for asynchronous serial communication in which the data format and transmission speeds are configurable. It sends data bits one by one, from the least significan ...
s could send 9 bits.


Microarchitecture

The microarchitecture of the Intel MCS8051 is proprietary, but published features suggest how it works. It is a
multi-cycle processor A multi-cycle processor is a processor that carries out one instruction over multiple clock cycles In electronics and especially synchronous digital circuits, a clock signal (historically also known as ''logic beat'') oscillates between a high and ...
. The MCS8051 used 12 clock cycles for most instructions. Many instructions utilize an accumulator. In contrast, most compatible computers execute instructions in one to three cycles, except for the multiply and divide instructions. The much higher speed is a major reason why these have replaced the MCS8051 in most applications. Each interrupt has four priorities. Within each priority, the interrupts of devices are in a fixed priority.


Instruction set

Instructions are all 1 to 3 bytes long, consisting of an initial opcode byte, followed by up to 2 bytes of operands. of the opcode bytes, ''x''0–''x''3, are used for irregular opcodes. of the opcode bytes, ''x''4–''x''F, are assigned to 16 basic ALU instructions with 12 possible operands. The least significant
nibble In computing, a nibble (occasionally nybble, nyble, or nybl to match the spelling of byte) is a four-bit aggregation, or half an octet. It is also known as half-byte or tetrade. In a networking or telecommunication context, the nibble is oft ...
of the opcode selects the primary operand as follows: * ''x''8–''x''F: Register direct, R0–R7. * ''x''6–''x''7: Register indirect, @R0 or @R1. * ''x''5: Memory direct, a following byte specifies an IRAM or SFR location. * ''x''4: Immediate, a following byte specifies an 8-bit constant. When the operand is a destination (, ) ''or'' the operation already includes an immediate source (, ), this instead specifies that the accumulator is used. The most significant nibble specifies the operation as follows. Not all support all addressing modes; the immediate mode in particular is unavailable when the primary operand is written to. Instruction mnemonics use ''destination'', ''source'' operand order. ; 0''y'' : Increment the specified operand. Immediate mode (opcode 0x04) specifies the accumulator, . ; 1''y'' : Decrement the specified operand. Immediate mode (opcode 0x14) specifies the accumulator, . ; 2''y'' : Add the operand to the accumulator, A. Opcode 0x23 (, "rotate left" but actually a
shift left In computer science, a logical shift is a bitwise operation that shifts all the bits of its operand. The two base variants are the logical left shift and the logical right shift. This is further modulated by the number of bit positions a gi ...
) may be thought of as . ; 3''y'' : Add the operand, plus the C bit, to the accumulator. Opcode 0x33 (, rotate left through carry) may be thought of as . ; 4''y'' : Logical OR the operand into the accumulator. Two memory-destination forms of this operation, and , are specified by opcodes 0x43 and 0x42. ; 5''y'' : Logical AND the operand into the accumulator. Two memory-destination forms of this operation, and , are specified by opcodes 0x53 and 0x52. ; 6''y'' : Logical exclusive-OR the operand into the accumulator. Two memory-destination forms of this operation, and , are specified by opcodes 0x63 and 0x62. ; 7''y'' : Move immediate to the operand. Immediate mode (opcode 0x74) specifies the accumulator, . ; 8''y'' : Move value to an IRAM or SFR register. Immediate mode (opcode 0x84) is not used for this operation, as it duplicates opcode 0x75. ; 9''y'' : Subtract the operand from the accumulator. This operation borrows and there is no subtract ''without'' borrow. ; A''y'' : Move value from an IRAM or SFR register. Immediate mode (opcode 0xA4) is not used, as immediates serve only as sources. Memory direct mode (opcode 0xA5) is not used, as it duplicates 0x85. ; B''y'' : Compare ''operand'' to the immediate , and jump to if not equal. Immediate and memory direct modes (opcodes 0xB4 and 0xB5) compare the operand against the accumulator, . Note that there is no compare and jump if equal instruction, . ; C''y'' : Exchange the accumulator and the operand. Immediate mode (opcode 0xC4) is not used for this operation. ; D''y'' : Decrement the operand, and jump to if the result is non-zero. Immediate mode (opcode 0xD4), and register indirect mode (0xD6, 0xD7) are not used. ; E''y'' : Move operand to the accumulator. Immediate mode is not used for this operation (opcode 0xE4), as it duplicates opcode 0x74. ; F''y'' : Move accumulator to the operand. Immediate mode (opcode 0xF4) is not used, as it would have no effect. Only the , , and instructions set PSW flags. The , , and logical instructions do not. The instruction modifies the C bit only, to the borrow that results from . The irregular instructions comprise 64 opcodes, having more limited addressing modes, plus several opcodes scavenged from inapplicable modes in the regular instructions. ; A5: ''Unused'' ; B5: ; D6–7: exchange low-order nibble of operands. The (short jump) opcode takes a signed relative offset byte operand and transfers control there relative to the address of the following instruction. The / opcodes combine the three most significant bits of the opcode byte with the following byte to specify an 11-bit destination that is used to replace 11 bottom bits of the PC register (top 5 bits of PC register remain intact). For larger addresses, the and instructions allow a 16-bit destination. One of the reasons for the 8051's popularity is its range of operations on single bits. Bits are always specified by absolute addresses; there is no register-indirect or indexed addressing. Instructions that operate on single bits are: * , , : Set, clear, or complement the specified bit * : Jump if bit set * : Jump if bit clear * : Jump if bit set, and clear bit * , : Move the specified bit to the carry bit, or vice versa * , : Or the bit (or its complement) to the carry bit * , : And the bit (or its complement) to the carry bit A bit operand is written in the form . Because the carry flag is bit 7 of the bit-addressable program status word, the , and instructions are shorter equivalents to , and . Although most instructions require that one operand is the accumulator or an immediate constant, opcode 0x85 performs directly between two internal RAM locations.


Programming

There are various
high-level programming language In computer science, a high-level programming language is a programming language with strong Abstraction (computer science), abstraction from the details of the computer. In contrast to low-level programming languages, it may use natural language ...
compilers for the 8051. Several C compilers are available for the 8051, most of which allow the programmer to specify where each variable should be stored in its six types of memory, and provide access to 8051 specific hardware features such as the multiple register banks and bit manipulation instructions. There are many commercial C compilers.
Small Device C Compiler The Small Device C Compiler (SDCC) is a free-software, partially retargetable C compiler for 8-bit microcontrollers. It is distributed under the GNU General Public License. The package also contains an assembler, linker, simulator and debugger. ...
(SDCC) is a popular open source C compiler. Other high level languages such as
C++ C++ (pronounced "C plus plus") is a high-level general-purpose programming language created by Danish computer scientist Bjarne Stroustrup as an extension of the C programming language, or "C with Classes". The language has expanded significan ...
,
Forth Forth or FORTH may refer to: Arts and entertainment * ''forth'' magazine, an Internet magazine * ''Forth'' (album), by The Verve, 2008 * ''Forth'', a 2011 album by Proto-Kaw * Radio Forth, a group of independent local radio stations in Scotla ...
, Bradford J. Rodriguez
"CamelForth/8051"
Brad Rodriguez

BASIC BASIC (Beginners' All-purpose Symbolic Instruction Code) is a family of general-purpose, high-level programming languages designed for ease of use. The original version was created by John G. Kemeny and Thomas E. Kurtz at Dartmouth College ...
,
Object Pascal Object Pascal is an extension to the programming language Pascal (programming language), Pascal that provides object-oriented programming (OOP) features such as Class (computer programming), classes and Method (computer programming), methods. ...
,
Pascal Pascal, Pascal's or PASCAL may refer to: People and fictional characters * Pascal (given name), including a list of people with the name * Pascal (surname), including a list of people and fictional characters with the name ** Blaise Pascal, Fren ...
,
PL/M The PL/M programming language (an acronym of ''Programming Language for Microcomputers'') is a high-level language conceived and developed by Gary Kildall in 1973 for Hank Smith at Intel for its microprocessors. Overview The language incorpor ...
and Modula-2 are available for the 8051, but they are less widely used than C and Assembly language, assembly. Because IRAM, XRAM, and PMEM (read only) all have an address 0, C compilers for the 8051 architecture provide compiler-specific Directive (programming), pragmas or other extensions to indicate where a particular piece of data should be stored (i.e. constants in PMEM or variables needing fast access in IRAM). Since data could be in one of three memory spaces, a mechanism is usually provided to allow determining to which memory a pointer refers, either by constraining the pointer type to include the memory space, or by storing metadata with the pointer.


Related processors

Intel discontinued its MCS-51 product line in March 2007; however, there are plenty of enhanced 8051 products or silicon intellectual property added regularly from other vendors. The 8051's predecessor, the Intel MCS-48, 8048, was used in the keyboard of the first IBM PC, where it converted keypresses into the serial data stream which is sent to the main unit of the computer. An Intel 8049 served a similar role in the Sinclair QL. The 8048 and derivatives are still used for basic model keyboards. The 8031 was a reduced version of the original 8051 that had no internal program memory (
read-only memory Read-only memory (ROM) is a type of non-volatile memory used in computers and other electronic devices. Data stored in ROM cannot be electronically modified after the manufacture of the memory device. Read-only memory is useful for storing sof ...
, ROM). To use this chip, external ROM had to be added containing the program that the 8031 would fetch and execute. An 8051 chip could be sold as a ROM-less 8031, as the 8051's internal ROM is disabled by the normal state of the EA pin in an 8031-based design. A vendor might sell an 8051 as an 8031 for any number of reasons, such as faulty code in the 8051's ROM, or simply an oversupply of 8051s and undersupply of 8031s. The 8052 was an enhanced version of the original 8051 that featured 256 bytes of internal RAM instead of 128 bytes, 8 KB of ROM instead of 4 KB, and a third 16-bit timer. Most modern 8051-compatible microcontrollers include these features. The 8032 had these same features as the 8052 except lacked internal ROM program memory. The 8751 was an 8051 with 4 KB EPROM instead of 4 KB ROM. They were identical except for the non-volatile memory type. This part was available in a ceramic package with a clear quartz window over the top of the die so Ultraviolet#Electrical and electronics industry, UV light could be used to erase the EPROM. Related parts are: 8752 had 8 KB EPROM, 8754 had 16 KB EPROM, 8758 had 32 KB EPROM. The 80C537 (ROM-less) and 80C517 (8 KB ROM) are
CMOS Complementary metal–oxide–semiconductor (CMOS, pronounced "sea-moss", ) is a type of metal–oxide–semiconductor field-effect transistor (MOSFET) fabrication process that uses complementary and symmetrical pairs of p-type and n-type MOSFE ...
versions, designed for the automotive industry. Enhancements mostly include new and enhanced peripherals. The 80C5x7 has fail-safe mechanisms, analog signal processing facilities, enhanced timer capabilities, and a 32-bit arithmetic peripheral. Other features include: * 256-byte on-chip RAM * 256 directly addressable bits * External program and data memory expandable up to 64 KB * 8-bit A/D converter with 12 multiplexed inputs * Arithmetic peripheral can perform 16×16→32-bit multiplication, 32/16→16-bit division, 32-bit shift and 32-bit normalize operations * Eight data pointers instead of one for indirect addressing of program and external data memory * Extended watchdog facilities * Nine I/O ports * Two full-duplex serial interfaces with individual baud rate generators * Four priority level interrupt systems, 14 interrupt vectors * Three power saving modes File:Intel_D87C51_AMD.jpg, AMD D87C51 File:MBL8031AH.jpg, Fujitsu MBL8031AH File:Ic-photo-MHS--S-80C31--(8031-MCU).png, MHS S-80C31 File:Ic-photo-OKI--M80C31F--(8031-MCU).JPG, Oki Electric Industry, OKI M80C31 File:Ic-photo-Philips--80C31BH-3 16P--(8031-MCU).png, Philips PCB80C31 File:Ic-photo-Signetics--SCN8031H--(8031-MCU).JPG, Signetics SCN8031 File:Ic-photo-Temic--TS80C32X2-MCB-(8032-MCU).png, Temic TS80C32X2


Derivative vendors

More than 20 independent manufacturers produce MCS-51 compatible processors. File:Atmel 89c2051 gfdl.jpg,
Atmel Atmel Corporation was a creator and manufacturer of semiconductors before being subsumed by Microchip Technology in 2016. Atmel was founded in 1984. The company focused on embedded systems built around microcontrollers. Its products included micr ...
Atmel AT89 series, AT89C2051 File:SAB-C515-LN.jpg, Infineon SAB-C515 File:EPROM-Microcontroller Philips 87C654.jpg, Philips S87C654 File:Ic-photo-Siemens--SAB-C501G-1RP-(MCU).png, Siemens SAB-C501 File:STC89C52.jpg, STC Micro STC89C52
Other ICs or IPs compatible with the MCS-51 have been developed by Analog Devices, Integral Minsk, Kristall Kyiv, and NIIET Voronezh.


Use as intellectual property

Today, 8051s are still available as discrete parts, but they are mostly used as silicon intellectual property cores. Available in hardware description language source code (such as VHDL or Verilog) or Field-programmable gate array, FPGA netlist forms, these cores are typically integrated within embedded systems, in products ranging from USB flash drives to washing machines to complex wireless communication System on a chip, systems on a chip. Designers use 8051 silicon IP cores, because of the smaller size, and lower power, compared to 32 bit processors like ARM Cortex-M, ARM Cortex-M series, MIPS architecture, MIPS and BA22. Modern 8051 cores are faster than earlier packaged versions. Design improvements have increased 8051 performance while retaining compatibility with the original MCS 51 instruction set. The original Intel 8051 ran at 12 clock cycles per machine cycle, and most instructions executed in one or two machine cycles. A typical maximum clock frequency of 12 MHz meant these old 8051s could execute one million single-cycle instructions, or 500,000 two-cycle instructions, per second. In contrast, enhanced 8051 silicon IP cores now run at one clock cycle per machine cycle, and have clock frequencies of up to 450 MHz. That means an 8051-compatible processor can now execute instructions per second.


MCUs based on 8051

* ABOV: MC94F, MC95F, MC96F series * Infineon: XC800 * Maxim Integrated (formerly Dallas): DS80-series etc. * Mentor Graphics: M8051EW etc. designed for Mentor by SYNTILL8 * Megawin: 74, 82, 84, 86, 87, and 89 series *Microchip (formerly Atmel): Atmel AT89 series, AT89C51, AT89S51, AT83C5134, etc. * NXP: NXP700 and NXP900 series * Siemens SAB 80532-N * Siemens SDA 30C164-2 (ROMless Processor) * Silergy electricity metering System On Chip, SoCs: 71M6511, 71M6513, 71M6531, 71M6533, 71M6534, 71M6542, 71M6543 Energy measurement System On Chip, SoCs: 78M6631, 78M6618, 78M6613, 78M6612 * Silicon Labs: C8051 series and EFM8 series * Silicon Storage Technology: FlashFlex51 MCU (SST89E52RD2, SST89E54RD2, SST89E58RD2, SST89E516RD2SST89V52RD2, SST89V54RD2, SST89V58RD2, SST89V516RD2) * STC Micro: STC89C51RC, STC90C51RC, STC90C58AD, STC10F08XE, STC11F60XE, STC12C5410AD, STC12C5202AD, STC12C5A60S2, STC12C5628AD, STC15F100, STC15F204EA, STC15F2K60S2, STC15F4K60S2, STC15F101W, STC15F408AD, STC15W104, STC15W408S, STC15W201S, STC15W408AS, STC15W1K16S and STC15W4K56S4 series * Texas Instruments CC111x, CC24xx and CC25xx families of RF SoCs * WCH (Nanjing Qinheng Microelectronics): CH551, CH552, CH554, CH546, CH547, CH548, CH558, CH559


Digital signal processor (DSP) variants

Several variants with an additional 16-bit
digital signal processor A digital signal processor (DSP) is a specialized microprocessor chip, with its architecture optimized for the operational needs of digital signal processing. DSPs are fabricated on MOS integrated circuit chips. They are widely used in audio si ...
(DSP) (for example for MP3 or Vorbis coding/decoding) with up to 675 million instructions per second (MIPS) and integrated USB 2.0 interface or as intellectual property exist.


Enhanced 8-bit binary compatible microcontroller: MCS-151 family

In 1996 Intel announced the MCS-151 family, an up to 6 times faster variant, that's fully binary and instruction set compatible with 8051. Unlike their 8051 MCS-151 is a pipelined CPU, with 16-bit internal code bus and is 6x the speed. The MCS-151 family was also discontinued by Intel, but is widely available in binary compatible and partly enhanced variants.


8/16/32-bit binary compatible microcontroller: MCS-251 family

The 80251 8/16/32-bit microcontroller with 16 MB (24-bit computing, 24-bit) address-space and 6 times faster instruction cycle was introduced by Intel in 1996. It can perform as an 8-bit 8051, has 24-bit Flat memory model, linear addressing, an 8-bit ALU, 8-bit instructions, 16-bit instructions, a limited set of 32-bit instructions, 16 8-bit registers, 16 16-bit registers (8 16-bit registers which do not share space with any 8-bit registers, and 8 16-bit registers which contain 2 8-bit registers per 16-bit register), and 10 32-bit registers (2 dedicated 32-bit registers, and 8 32-bit registers which contain 2 16-bit registers per 32-bit register). It features extended instructions – see also the programmer's guide – and later variants with higher performance, also available as intellectual property (IP).R80251XC 32bit Microcontroller
Evatronix
It is 3-stage pipelined. The MCS-251 family was also discontinued by Intel, but is widely available in binary compatible and partly enhanced variants from many manufacturers.


See also

* DS80C390 * Hitachi HD44780 - LCD controller with XRAM-compatible interface * Intel PL/M-51 * Intel System Development Kit#Intel SDK-51, SDK-51 System Design Kit


References


Further reading

;Books * * * * * * ;Intel *
MCS-51 Microcontroller Family User's Manual
'; Intel; 1994; publication number 121517. * ''MCS-51 Macro Assembler User's Guide''; Intel; publication number 9800937. * ''8-Bit Embedded Controllers''; Intel; 1991; publication number . * ''Microcontroller Handbook''; Intel; 1984; publication number . *
8051 Microcontroller Preliminary Architectural Specification and Functional Description
'; Intel; 44 pages; 1980. ;Misc *

https://web.archive.org/web/20210806202253/https://www.dos4ever.com/8031board/SIM51_06.zip] (Besides the elektor assembler hex format, EASM format, the HEX.DOC file discusses various hex file formats by Intel HEX, Intel, SREC (file format), Motorola, Tektronix hex format, Tektronix, MOS Technology file format, MOS Technology and elektor.)


External links


Complete tutorial for 8051 microcontrollers

the source website for tutorials and simulator for 8051



Open source VHDL 8051 implementation (Oregano Systems)
{{DEFAULTSORT:Intel Mcs-51 Intel microcontrollers