INTEL 8051 MICROCONTROLLER

The Intel 8051 is a Harvard architecture, single chip microcontroller (µC) which was developed by Intelin 1980 for use in embedded systems. Intel's original versions were popular in the 1980s and early 1990s, but has today largely been superseded by a vast range of faster and/or functionally enhanced 8051-compatible devices manufactured by more than 20 independent manufacturers including Atmel,Infineon Technologies (formerly Siemens AG), Maxim Integrated Products (via its Dallas Semiconductorsubsidiary), NXP (formerly Philips Semiconductor), Nuvoton (formerly Winbond), ST Microelectronics,Silicon Laboratories (formerly Cygnal), Texas Instruments and Cypress Semiconductor. Intel's official designation for the 8051 family of µCs is MCS 51.

Intel's original 8051 family was developed using NMOS technology, but later versions, identified by a letter C in their name (e.g., 80C51) used CMOS technology and were less power-hungry than their NMOS predecessors. This made them more suitable for battery-powered devices.

Contents

[hide]
  • 1 Important features and applications
  • 2 Programming
  • 3 Instruction set
  • 4 Related processors
  • 5 References
  • 6 External links

[edit]Important features and applications

i8051 microarchitecture.
  • It provides many functions (CPU, RAM, ROM, I/O, interrupt logic, timer, etc.) in a single package
  • 8-bit ALU, Accumulator and Registers; hence it is an 8-bit microcontroller
  • 8-bit data bus - It can access 8 bits of data in one operation
  • 16-bit address bus - It can access 216 memory locations - 64 kiB (65536 locations) each of RAM and ROM
  • On-chip RAM - 128 bytes (data memory)
  • On-chip ROM - 4 kiB (program memory)
  • Four byte bi-directional input/output port
  • UART (serial port)
  • Two 16-bit Counter/timers
  • Two-level interrupt priority
  • Power saving mode

A particularly useful 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 internal registers and RAM. This feature helped to cement the 8051's popularity in industrial control applications. Another valued feature is that it has four separate register sets, which can be used to greatly reduce interrupt latency compared to the more common method of storing interrupt context on a stack.

The 8051 UARTs make it simple to use the chip as a serial communications interface. External pins can be configured to connect to internal shift registers in a variety of ways, and the internal timers can also be used, allowing serial communications in a number of modes, both synchronous and asynchronous. Some modes allow communications with no external components. A mode compatible with an RS-485 multi-point communications environment is achievable, but the 8051's real strength is fitting in with existing ad-hoc protocols (e.g., when controlling serial-controlled devices).

Once a UART, and a timer if necessary, have been configured, the programmer needs only to write a simple interrupt routine to refill thesend 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.

8051 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. 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, and have clock frequencies of up to 100 MHz, and are thus capable of an even greater number of instructions per second. All SILabs, some Dallas and a few Atmel devices have single cycle cores.

Even higher speed single cycle 8051 cores, in the range 130 MHz to 150 MHz, are now available in internet downloadable form for use inprogrammable logic devices such as FPGAs, and at many hundreds of MHz in ASICs, for example the netlist from www.e8051.com. Top clock speed 8051 cores reach over 200 MHz in today's FPGA technologies - as an example www.dcd.pl.

Common features included in modern 8051 based microcontrollers include built-in reset timers with brown-out detection, on-chip oscillators, self-programmable Flash ROM program memory, bootloader code in ROM, EEPROM non-volatile data storage, I²C, SPI, and USB host interfaces, CAN or LIN bus, PWM generators, analog comparators, A/D and D/A converters, RTCs, extra counters and timers, in-circuit debugging facilities, more interrupt sources, and extra power saving modes.

[edit]Programming

There are various high level language compilers for 8051. Several C compilers are available for the 8051, most of which feature extensions that 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. SDCC is a popular open source C compiler. Other high level languages such as Forth, BASIC, Pascal/Object Pascal, PL/M and Modula 2 are available for the 8051, but they are less widely used than C and assembly.

[edit]Instruction set

Arithmetic Operations

MnemonicDescriptionBytesCycles
ADD A,RnAdd register to A11
ADD A,directAdd direct byte to A21
ADD A,@RiAdd indirect RAM to A11
ADD A,#dataAdd immediate data to A21
ADDC A,RnAdd register to A with Carry11
ADDC A,directAdd direct byte to A with Carry21
ADDC A,@RiAdd indirect RAM to A with Carry11
ADDC A,#dataAdd immediate data to A with Carry21
SUBB A,RnSubtract register from A with Borrow11
SUBB A,directSubtract direct byte from A with Borrow21
SUBB A,@RiSubtract indirect RAM from A with Borrow11
SUBB A,#dataSubtract immediate data from A with Borrow21
INC AIncrement A11
INC RnIncrement register11
INC directIncrement direct byte21
INC @RiIncrement indirect RAM11
DEC ADecrement A11
DEC RnDecrement register11
DEC directDecrement direct byte21
DEC @RiDecrement indirect RAM11
INC DPTRIncrement Data Pointer12
MUL ABMultiply A and B (A x B => BA)14
DIV ABDivide A by B (A/B => A + B)14
DA ADecimal Adjust A11

Logical Operations

MnemonicDescriptionBytesCycles
ANL A,RnAND register to A11
ANL A,directAND direct byte to A21
ANL A,@RiAND indirect RAM to A11
ANL A,#dataAND immediate data to A21
ANL direct,AAND A to direct byte21
ANL direct,#dataAND immediate data to direct byte32
ORL A,RnOR register to A11
ORL A,directOR direct byte to A21
ORL A,@RiOR indirect RAM to A11
ORL A,#dataOR immediate data to A21
ORL direct,AOR A to direct byte21
ORL direct,#dataOR immediate data to direct byte32
XRL A,RnExclusive-OR register to A11
XRL A,directExclusive-OR direct byte to A21
XRL A,@RiExclusive-OR indirect RAM to A11
XRL A,#dataExclusive-OR immediate data to A21
XRL direct AExclusive-OR A to direct byte21
XRL direct,#dataExclusive-OR immediate data to direct byte32
CLR AClear A11
CPL AComplement A11
RL ARotate A Left11
RLC ARotate A Left through Carry11
RR ARotate A Right11
RRC ARotate A Right through Carry11
SWAP ASwap nibbles within A11

Data Transfer Operations

MnemonicDescriptionBytesCycles
MOV A,RnMove register to A11
MOV A,directMove direct byte to A21
MOV A,@RiMove indirect RAM to A11
MOV A,#dataMove immediate data to A21
MOV Rn,AMove A to register11
MOV Rn,directMove direct byte to register22
MOV Rn,#dataMove immediate data to register21
MOV direct,AMove A to direct byte21
MOV direct,RnMove register to direct byte22
MOV direct,directMove direct byte to direct byte32
MOV direct,@RiMove indirect RAM to direct byte22
MOV direct,#dataMove immediate data to direct byte32
MOV @Ri,AMove A to indirect RAM11
MOV @Ri,directMove direct byte to indirect RAM22
MOV @Ri,#dataMove immediate data to indirect RAM21
MOV DPTR,#data16Load Data Pointer with 16-bit constant31
MOVC A,@A+DPTRMove Code byte relative to DPTR to A12
MOVC A,@A+PCMove Code byte relative to PC to A12
MOVX A,@RiMove External RAM (8-bit addr) to A12
MOVX A,@DPTRMove External RAM (16-bit addr) to A12
MOVX @Ri,AMove A to External RAM (8-bit addr)12
MOVX @DPTRA Move A to External RAM (16-bit addr)12
PUSH directPush direct byte onto stack22
POP directPop direct byte from stack22
XCH A,RnExchange register with A11
XCH A,directExchange direct byte with A21
XCH A,@RiExchange indirect RAM with A11
XCHD A,@RiExchange low-order Digit indirect RAM with A11

Single Bit (Boolean Variable) Operations

MnemonicDescriptionBytesCycles
CLR CClear Carry flag11
CLR bitClear direct bit21
SETB CSet Carry flag11
SETB bitSet direct bit21
CPL CComplement Carry flag11
CPL bitComplement direct bit21
ANL C,bitAND direct bit to Carry flag22
ANL C,/bitAND complement of direct bit to Carry flag22
ORL C,bitOR direct bit to Carry flag22
ORL C,/bitOR complement of direct bit to Carry flag22
MOV C,bitMove direct bit to Carry flag21
MOV bit,CMove Carry flag to direct bit22

Program Flow Control

MnemonicDescriptionBytesCycles
ACALL addr11Absolute subroutine call22
LCALL addr16Long subroutine call32
RETReturn from subroutine12
RETIReturn from interrupt12
AJMP addr11Absolute Jump22
LJMP addr16Long Jump32
SJMP relShort Jump at relative address22
JMP @A+DPTRJump indirect relative to DPTR12
JZ relJump if A is Zero22
JNZ relJump if A is Not Zero22
JC relJump if Carry flag is set22
JNC relJump if No Carry flag22
JB bit,relJump if direct Bit is set32
JNB bit,relJump if direct Bit is Not set32
JBC bit,relJump if direct Bit is set and Clear bit32
CJNE A,direct,relCompare direct to A and Jump if Not Equal32
CJNE A,#data,relCompare immediate to A and Jump if Not Equal32
CJNE Rn,#data,relCompare immediate to register and Jump if Not Equal32
CJNE @Ri,#data,relCompare immediate to indirect and Jump if Not Equal32
DJNZ Rn,relDecrement register and Jump if Not Zero22
DJNZ direct,relDecrement direct byte and Jump if Not Zero32
NOPNo operation11

Notes

Rn Working register R0-R7


direct 128 internal RAM locations, any I/O port, control or status register


@Ri Indirect internal RAM location addressed by register R0 or R1


  1. data 8-bit constant included in instruction


  1. data16 16-bit constant included in instruction


bit 128 software flags, any I/O pin, control or status bit


addr16 Destination address may be anywhere in 64-kByte program address space


addr11 Destination address will be within same 2-kByte page of program address space as first byte of the following instruction


rel 8-bit offset relative to first byte of following instruction (+127, -128)


All mnemonics copyrighted (C) Intel Corporation 1979

rate it

top