The Intel MCS-51 (commonly termed 8051) is a single-chip microcontroller (MCU) series developed by Intel in 1980 for use in embedded systems. 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 derivatives remain popular today. It is a complex instruction set computer with 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) 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 MCS-151 and the 8/16/32-bit MCS-251 family of binary compatible microcontrollers.
- Multiply, divide and compare instructions
- Four fast switchable register banks with 8 registers each (memory-mapped)
- Fast interrupt with optional register bank switching
- Interrupts and threads with selectable priority
- 128 or 256 bytes of on-chip RAM (IRAM)
- Dual 16-bit address bus; it can access 2 × 2<sup>16</sup> memory locations: 64 KB (65,536 locations) each of ROM (PMEM) and external RAM (XRAM), using two memory buses in a Harvard architecture.
- On-chip ROM (not included on 803x variants)
- Four (three full) 8-bit bidirectional input/output ports, bit-addressable
- UART (serial port)
- Two 16-bit counters/timers
- Power-saving mode (on some derivatives)
One feature of the 8051 core is the inclusion of a Boolean processing engine, which allows bit-level Boolean logic operations to be carried out directly and efficiently on select internal registers, ports and select RAM locations. Another feature is the inclusion of four bank-selectable working register sets, which greatly reduce the time required to perform the context switches to enter and leave interrupt service routines. With one instruction, the 8051 can switch register banks, avoiding the time-consuming task of transferring the critical registers to RAM.
Derivative features
, new derivatives are still being developed by many major chipmakers, and major compiler suppliers such as IAR Systems, Keil and TASKING continuously release updates.
MCS-51-based microcontrollers typically include one or two UARTs, two or three timers, 128 or 256 bytes of internal data RAM (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, 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, thus being capable of an even greater number of instructions per second. All Silicon Labs, some Dallas (now part of Maxim Integrated) and a few Atmel (now part of Microchip) devices have single-cycle cores.
8051 variants may include built-in reset timers with brown-out detection, on-chip oscillators, self-programmable flash ROM program memory, built-in external RAM, extra internal program storage, bootloader code in ROM, EEPROM non-volatile data storage, I<sup>2</sup>C, SPI, and USB host interfaces, CAN or LIN bus, Zigbee or Bluetooth radio modules, PWM generators, analog comparators, analog-to-digital and digital-to-analog converters, RTCs, extra counters and timers, in-circuit debugging facilities, more interrupt sources, extra power-saving modes, more or fewer parallel ports etc. Intel manufactured a mask-programmed version, 8052AH-BASIC, with a BASIC 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 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) as the UT69RH051 or from NIIET as the 1830VE32 ().
Family naming conventions
Intel's first MCS-51 microcontroller was the 8051, 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. 8031 and 8032 are ROM-less versions, with 128 and 256 bytes of 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
right|thumb|Die shot of 8751 with 4 KB EPROM and 128 bytes of RAM
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 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 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 <code>@R0</code> or <code>@R1</code> syntax, or as stack memory through the stack pointer SP, with the <code>PUSH</code>/<code>POP</code> and <code>*CALL</code>/<code>RET</code> 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 0x80–0xFF 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 <code>@R0</code> or <code>@R1</code> 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 registers of timer 2 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 to 0x1F contain space for four 8-byte register windows, which the eight 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 contain 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 of the 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 tables 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 64 KB is required, a common system makes the code bank-switched, with general-purpose I/O selecting the upper address bits. Some 8051 compilers 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, features suggest how it works. It is a multi-cycle processor. The MCS8051 used 12 clock cycles Small Device C Compiler (SDCC) is a popular open-source C compiler.
Other high level languages such as C++, Forth,
BASIC, Object Pascal, Pascal, PL/M and Modula-2 are available for the 8051, but they are less widely used than C and assembly.
Because IRAM, XRAM, and PMEM (read only) all have an address 0, C compilers for the 8051 architecture provide compiler-specific 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
thumb|right|Intel 8031 microcontrollers
thumb|right|Intel D87C51 microcontroller
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 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 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.
thumb|Intel P8044AH microcontroller
The 8044 (as well as the ROM-less 8344 and the 8744 with EPROM) added an SDLC controller to the 8051 core (especially for Bitbus applications).
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 it 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 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 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
<gallery mode="packed" heights="150px" caption="Intel MCS-51 second sources">
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 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
</gallery>
Derivative vendors
More than 20 independent manufacturers produce MCS-51 compatible processors.
<gallery mode="packed" heights="150px" caption="Intel MCS-51 derived microcontrollers">
File:Atmel 89c2051 gfdl.jpg|Atmel 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
</gallery>
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 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 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 series, MIPS and BA22.
Subsequent 8051 core designs have increased performance while retaining compatibility with the original MCS-51 instruction set. The original Intel 8051 was a microcode engine using 12 clocked microcode cycles per machine cycle to minimize the number of NMOS logic gates consuming power in passive resistive pull-ups. Most instructions executed in one or two machine cycles. At the typical maximum clock frequency of 12 MHz, the original 8051 types execute one million single-cycle instructions, or 500,000 two-cycle instructions, per second. The change to CMOS using active P-channel FET pull-ups makes it possible to realize the core without microcode. Enhanced 8051 IP cores run at one clock cycle per machine cycle. With clock frequencies of up to 450 MHz an 8051-compatible processor can execute up to 450 million instructions per second.
MCUs based on 8051
thumb|Silicon Storage Technology 89V54RD2
- ABOV: MC94F, MC95F, MC96F series
- Analog Devices (formerly Maxim Integrated, originally Dallas): DS80-series etc.
- Cypress PSoC CY8C3xxxx series, which has a dedicated USB 2.0 interface
- Jin Rui (brand CACHIP): CA51Fx family 8-bit MCUs.
- Infineon: XC800
- Mentor Graphics: M8051EW etc. designed for Mentor by SYNTILL8
- Megawin: 74, 82, 84, 86, 87, and 89 series
- Microchip (formerly Atmel): AT89C51, AT89S51, AT83C5134, etc.
- Silergy electricity metering SoCs: 71M6511, 71M6513, 71M6531, 71M6533, 71M6534, 71M6542, 71M6543 Energy measurement SoCs: 78M6631, 78M6618, 78M6613, 78M6612
- Silicon Labs: C8051 series and EFM8 series
- 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
- Taifatech TF470, single-cycle RISC backend
- 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 (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) address-space and six times faster instruction cycle was introduced by Intel in 1996. It can perform as an 8-bit 8051, has 24-bit 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 of which overlap with pairs of 8-bit registers), and 10 32-bit registers (8 of which overlap with pairs of 16-bit registers).
It features extended instructions and later variants with higher performance. It is also available as intellectual property (IP). 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.
The 80251 new instructions are assigned opcodes in the range x8–xF, and are selected using the formerly unused opcode A5 as an opcode prefix in one of two ways:
- In "binary mode," operation is fully 8051 compatible, and all new instructions must be prefixed with A5.
- In "source mode," existing 8051 code must have an A5 prefix byte added to all 8051 instructions in the range x6–xF. (This is usually done by the assembler.) Unprefixed opcode bytes in this range encode the new 80251 instructions. (Opcode bytes x6–x7 are not assigned, but are available for future expansion.)
Generally<!--The exceptions being 0xAA ERET and 0xB9 TRAP-->, the new 80251 instructions are two bytes long (not including the A5 prefix), with the first byte specifying the operation, and the second encoding two 4-bit register operands, or one register operand and four additional opcode bits.
See also
- DS80C390
- Hitachi HD44780 - LCD controller with XRAM-compatible interface
- Intel PL/M-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/SIM51D_BASIC.zip][https://web.archive.org/web/20210806202253/https://www.dos4ever.com/8031board/SIM51_06.zip] (Besides the EASM format, the HEX.DOC file discusses various hex file formats by Intel, Motorola, Tektronix, MOS Technology and elektor.)
External links
- Complete tutorial for 8051 microcontrollers
- the source website for tutorials and simulator for 8051
- Basic 8051 Interfacing Circuits
- Open source VHDL 8051 implementation (Oregano Systems)
