Chapter 2 Introduction To 8051
Chapter 2 Introduction To 8051
CPU
Bus Serial
4 I/O Ports
OSC Control Port
P0 P1 P2 P3 TxD RxD
Address/Data
Microcontroller basics 8051 family
• The microcontroller usually referred as 8051
has many variants from different
manufacturers
Comparison of the 8051 Family Members
20
128 bytes of Internal RAM Structure
The lower 32 bytes are divided into 4 separate banks. Each register
bank has 8 registers of one byte each. A register bank is selected
depending upon two bank select bits in the PSW register. Next
16bytes are bit addressable. In total, 128bits (16X8) are available
in bit addressable area. Each bit can be accessed and modified by
suitable instructions. The bit addresses are from 00H (LSB of the
first byte in 20H) to 7FH (MSB of the last byte in 2FH).
Remaining 80bytes of RAM are available for general purpose.
21
The microprocessor performs primarily four operations:
I. Memory Read: Reads data (or instruction) from memory.
II. Memory Write: Writes data (or instruction) into memory.
III. I/O Read: Accepts data from input device.
IV. I/O Write: Sends data to output device.
The 8051 processor performs these functions using address bus,
data bus and control bus.
22
Microcontroller basics 8051
• Clock connection
– For 8051 microcontroller operation, one of the
external inputs needed is the clock.
– There are three variations for this
Microcontroller basics 8051
• A machine cycle in 8051 contains six states or
12 clock cycles
Microcontroller basics 8051
• Reset operation
– The other external input in 8051 is the reset input
– It is activated by making pin 9 high
– When reset occurs
• Program counter is cleared
• Register bank 0 is selected
• Stack pointer is initialized to 07H
• All ports are written with FFh
Microcontroller basics 8051
The basic setup of microcontroller
27
The basic setup of microcontroller
28
The basic setup of microcontroller (Contd.)
This is a module that has been prepared by us. You can see that a
40 pin base has been mounted on the PCB (printed circuit board)
instead of directly soldering the microcontroller to PCB which
maybe damaged while soldering.
29
The basic setup of microcontroller (Contd.)
30
8051 Microcontroller Instruction set
• Instruction set
– Has more than 110 instructions
– Can be grouped into 5 categories
– These are
• Arithmetic instructions
• Logical instructions
• Data transfer instructions
• Bit manipulation instructions
• Program branching and control
8051 INSTRUCTION SET
Arithmetic logical Data transfer Bit Program
manipulation control
ADD, ADDC, ANL,ORL, MOV, MOVX, CLR, SETB, CPL, ACALL, LCALL,
SUBB, INC, XRL,CLR,CPL,RL MOVC, PUSH, ANL, ORL, RET, RETI,
DEC, MUL, DIV, ,RLC,RR,RRC,S POP, XCH, MOV, JC, JNC, AJMP, LJMP,
DA WAP XCHD JB, JNB, JBC SJMP, JMP, JZ,
JNZ, CJNE,
DJNC, NOP
8051 Addressing modes
• An instruction consists of an op code and
operand
Applications of 8051:
37
PIC microcontrollers
• Originally product of general instruments but latter
transferred to microchip
– PIC 1650 and 1655 8 bit microcontroller
– Faster speed, low cost, easier prototyping and simpler
chip set
• Basic features
– 8 bit microcontrollers
– Self contained (have internal program and data memory)
– Have single accumulator
–
PIC microcontroller family
• Basic families of PIC controller
PIC microcontrollers
• The most famous family of the PIC
microcontrollers is the 16 series/ family
• As a family, they have identical core and
instruction set
• However, they have different package sizes,
internal memory capacity, number of
peripheral devices etc