Anda di halaman 1dari 22

A presentation on microcontroller 8051

Presented byYASH VIJAYVERGIYA Roll no.0112ec061107

8051 belongs to MCS-51 family of microcontrollers MCS-51 was developed by Intel but other manufacturers (e.g., Siemens, Philips) are second sources of this family. Features of the standard 8051 4K bytes internal ROM (program) 128 bytes internal RAM (data) Four 8-bit I/O ports Two 16-bit timers Serial interface 64K external code memory space 64K external data memory space 210 bit-addressable locations

Microprocessors vs. Microcontrollers

Microprocessors are single-chip CPUs used in microcomputers Microcontrollers and microprocessors are different in three main aspects: hardware architecture, applications, and instruction set features Hardware architecture: A microprocessor is a single chip CPU while a microcontroller is a single IC contains a CPU and much of remaining circuitry of a complete computer (e.g., RAM, ROM, serial interface, parallel interface, timer, interrupt handling circuit) Applications: Microprocessors are commonly used as a CPU in computers while microcontrollers are found in small, minimum component designs performing control oriented activities.

Instruction set: Microprocessor instruction sets are processing Intensive Their instructions operate on nibbles, bytes, words, or even double words.

Addressing modes provide access to large arrays of data using pointers and offsets.
Microcontroller instruction sets cater to control of inputs and outputs They have instructions to set and clear individual bits and perform bit operations. They have instructions for input/output operations, event timing, enabling and setting priority levels for interrupts caused by external stimuli. Processing power of a microcontroller is much less than a microprocessor

8051 implements a separate memory space for programs (code) and data. Both code and data may be internal, however, both expand using external components to a maximum of 64K code memory and 64K data memory. Internal memory consists of on-chip ROM and on-chip data RAM. On-chip RAM contains a rich arrangement of general purpose storage, bit addressable storage, register banks, and special function registers. In the 8051, the registers and input/output ports are memory mapped and accessible like any other memory location. In the 8051, the stack resides within the internal RAM, rather than in external RAM.

Bit Addressable RAM

Individual accessing of bits is a powerful feature of microcontrollers Bits can be set, cleared, ANDed, ORed etc, with a single instruction 8051 ports are bit-addressable, simplifying the interface to single bit inputs and outputs. The 8051 contains 210 bit-addressable locations 128 of these locations are at addresses 20H to 2FH and the rest are in the special function registers

Register Banks
The bottom 32 locations of internal memory contain the register banks 8051 supports 8 registers R0 to R7 and after a system reset (default) the registers are at address 00H to 07H MOV A, R5: reads the content of address 05H into the accumulator MOV A,05H will do the same thing The active register bank may be altered by changing the register bank select bits in the Program Status Word (PSW) Idea of register banks permits fast and effective context switching

Special Function Registers 8051 has 21 special function registers (SFRs) at the top of internal RAM from address 80H to FFH. Most of the addresses from 80H to FFH are not defined, except for 21 of them. Some SFRs are both bit-addressable and byte addressable, depending on the instruction accessing the register

Block Diagram
External interrupts Interrupt Control On-chip ROM for program code

On-chip RAM

Timer 1 Timer 0

Counter Inputs

Serial Port


Bus Control

4 I/O Ports

P0 P1 P2 P3



Pin Description of the 8051

P1.0 P1.1 P1.2 P1.3 P1.4 P1.5 P1.6 P1.7 RST (RXD)P3.0 (TXD)P3.1 (INT0)P3.2 (INT1)P3.3 (T0)P3.4 (T1)P3.5 (WR)P3.6 (RD)P3.7 XTAL2 XTAL1 GND 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 Vcc P0.0(AD0) P0.1(AD1) P0.2(AD2) P0.3(AD3) P0.4(AD4) P0.5(AD5) P0.6(AD6) P0.7(AD7) EA/VPP ALE/PROG PSEN P2.7(A15) P2.6(A14) P2.5(A13) P2.4(A12) P2.3(A11) P2.2(A10) P2.1(A9) P2.0(A8)

1 3P 2 2P P 3 3P 4 2E 5 A 6 7 8 9 R ( 4V 1 X 1 2 G 14 S3 R0c 0 7A T90 1 6S I 82 2 5L 34 43 W0 52 61 70 89 T6 98 2 07 N5 1 . c T . X . N . 0 E 1 R / D A 0 5 1 3 2 4 1 3 7 4 0 5 V 6 1 6 7 3 D 0 / T 2 N ) 5 L 4 2 ( ) ( 0 P 1 ( P 2 1 P A R ) A 3 P D D 3 1 O P 9 . 8 1 3 4 5 6 7 . 0 G 3 2 4 3 5 2 6 4 7 1 0 ) ) 0 ) 1 ) . 2 3

8 0 5 1 ( 8 0 3 1 )

8051 (8031)

Vccpin 40 Vcc provides supply voltage to the chip. The voltage source is +5V. GNDpin 20ground XTAL1 and XTAL2pins 19,18 These 2 pins provide external clock. Way 1using a quartz crystal oscillator Way 2using a TTL oscillator Example 4-1 shows the relationship between XTAL and the machine cycle.

RSTpin 9reset It is an input pin and is active highnormally low.

The high pulse must be high at least 2 machine cycles. Upon applying a high pulse to RST, the microcontroller will reset and all values in registers will be lost. Reset values of some 8051 registers

It is a power-on reset.

Way 1Power-on reset circuit Way 2Power-on reset with debounce

/EApin 31external access There is no on-chip ROM in 8031 and 8032 . The /EA pin is connected to GND to indicate the code is stored externally. /PSEN ALE are used for external ROM. For 8051, /EA pin is connected to Vcc. / means active low. /PSENpin 29program store enable This is an output pin and is connected to the OE pin of the ROM.

RSTpin 9reset It is an input pin and is active highnormally low.

The high pulse must be high at least 2 machine cycles. Upon applying a high pulse to RST, the microcontroller will reset and all values in registers will be lost. Reset values of some 8051 registers

It is a power-on reset.

Way 1Power-on reset circuit Way 2Power-on reset with debounce

Important features :

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

Addressing Modes
Register Direct Register Indirect Immediate Relative Absolute Long Indexed

1. 2. 3.

Enabling and Disabling Interrupts Interrupt Priority Writing the ISR (Interrupt Service Routine)

Interrupt :


Popular - readily available and widely supported, a full range of free and commercial support products is available Low cost - high level of system integration within one component, only a handful of components needed to create a working system. Constant improvements - improvements in silicon/design increase speed

Wide range - One set of tools covers the greatest horsepower range of any microcontroller family, the 8051 provides a real cost savings in tools, training, and software support. - Compatibility - opcodes and binaries are the SAME for all 80x51 variants (unlike most other microcontroller families). Multi-sourced - over 12 manufacturers, hundreds of varieties, something for everyone with the security of ready availability.


Engine management systems in automobiles. Keyboard of a PC. Electronic measurement instruments (such as digital multimeters, frequency synthesisers, and oscilloscopes) Printers. Mobile phones. Televisions, radios, CD players, tape recording equipment. Hearing aids. Security alarm systems, fire alarm systems, and building services systems