0% found this document useful (0 votes)
41 views28 pages

8051 Microcontroller and Interfacing

Uploaded by

mofreh hogo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
41 views28 pages

8051 Microcontroller and Interfacing

Uploaded by

mofreh hogo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 28

8051 Microcontroller and

Interfacing

Prepared By
Mr.K.Ganesan,
Assistant Professor
Department of Electronics and Communication
Sri Ganesh College of Arts & Science,
Salem - 636014
Microcontroller
• A microcontroller is a compact integrated
circuit designed to govern a specific operation
in an embedded system. A typical
microcontroller includes a processor, memory
and input/output (I/O) peripherals on a single
chip.
8051 Pin Diagram
Pin diagram
• Pins 1 to 8 − These pins are known as Port 1. This port doesn’t serve any other functions. It is
internally pulled up, bi-directional I/O port.
• Pin 9 − It is a RESET pin, which is used to reset the microcontroller to its initial values.
• Pins 10 to 17 − These pins are known as Port 3. This port serves some functions like
interrupts, timer input, control signals, serial communication signals RxD and TxD, etc.
• Pins 18 & 19 − These pins are used for interfacing an external crystal to get the system clock.
• Pin 20 − This pin provides the power supply to the circuit.
• Pins 21 to 28 − These pins are known as Port 2. It serves as I/O port. Higher order address bus
signals are also multiplexed using this port.
• Pin 29 − This is PSEN pin which stands for Program Store Enable. It is used to read a signal
from the external program memory.
• Pin 30 − This is EA pin which stands for External Access input. It is used to enable/disable the
external memory interfacing.
• Pin 31 − This is ALE pin which stands for Address Latch Enable. It is used to demultiplex the
address-data signal of port.
• Pins 32 to 39 − These pins are known as Port 0. It serves as I/O port. Lower order address and
data bus signals are multiplexed using this port.
• Pin 40 − This pin is used to provide power supply to the circuit.
8051 Architecture
8051 Architecture

• 8051 micro controller is an 8 bit controller. Figure 1.1 shows the


architecture diagram of 8051.
• The 8051 microcontroller has the following features:
• 4 Kb of ROM.
• 128b of RAM (including SFRs) satisfies the user’s basic needs.
• 4 ports, each having 8 input/ouput lines, total of 32 input/output
lines are present which are sufficient to make all necessary
connections to peripheral environment.
• It has Accumulator, general purpose registers and special purpose
registers and
• It has ALU which does all kind of arithmetic and logical operations.
ALU:

• It is 8 bit unit

• It performs arithmetic operation as addition, subtraction, multiplication,


division, increment and decrement.
• It performs logical operations like AND, OR and EX-OR. It manipulates 8 bit and
16 bit data
• It calculates address of jump locations in relative branch instruction.

• It performs compare, rotate and compliment operations

• 8051 micro controller contains 34 general purpose registers or working registers


Accumulator(A-reg):
 It is 8 bit register
 It is bit and byte accessible
 Result of arithmetic & logic operations performed by ALU is
accumulated by this register.
 Therefore it is called accumulator register
 It is used to store 8 bit data and to hold one of operand of
ALU units during arithmetical and logical operations
 Most of the instructions are carried out on accumulator data.
B-register

• It is special 8 bit math register. It is bit and


byte accessible.

• It is used in conjunction with A register as I/P


operand for ALU. It is used as general purpose
register to store 8 bit data.
Program counter (PC):

• The Program Counter (PC) is a 2-byte address which


tells the 8051 where the next instruction to execute is
found in memory.

• It is used to hold 16 bit address of internal RAM,


external RAM or external ROM locations.

• It is important to note that PC isn’t always


incremented by one and never decremented.
Data pointer register (DTPR):
• It is a 16-bit register used to hold address of external or
internal RAM where data is stored or result is to be stored.
• It is used to store 16 bit data.

• Each register can be used as general purpose register to


store 8 bit data and can also be used as memory location.
• DPTR does not have single internal address.

• It functions as Base register in base relative addressing


mode and in-direct jump.
Stack pointer (SP):

• It is 8-bit register. It is byte addressable.

• Its address is 81H.

• It is used to hold the internal RAM memory location


addresses which are used as stack memory.
• When the data is to be placed on stack by push instruction,
the content of stack pointer is incremented by 1, and when
data is retrieved from stack, content of stack of stack
pointer is decremented by 1.
Special function Registers(SFR):

• The 8051 microcontroller has 11 SFR divided in 4 groups:

• Timer/Counter register

• 8051 microcontroller has 2-16 bit Timer/counter registers called Timer-


reg-T0 And Timer/counter Reg-T1.

• Each register is 16 bit register divide into lower and higher byte register

• These register are used to hold initial no. of count.

• All of the 4 register are byte addressable.


Timer control register

• 8051 microcontroller has two 8-bit timer control register i.e. TMOD and
TCON register.

TMOD Register:
• It is 8-bit register. Its address is 89H.
• It is byte addressable.
• It used to select mode and control operation of time by writing control word.

TCON register:
• It is 8-bit register. Its address is 88H. It is byte addressable.
• Its MSB 4- bit are used to control operation of timer/ counter and LSB 4-bit
are used for external interrupt control.
Serial data register:

• 8051 micro controller has 2 serial data register viz.


SBUF and SCON.

Serial buffer register (SBUF):


• It is 8-bit register.
• It is byte addressable .
• Its address is 99H.
• It is used to hold data which is to be transferred
serially.
Serial control register (SCON):
• It is 8-bit register.
• It is bit/byte addressable. Its address is 98H.
• The 8-bit loaded into this register controls the
operation of serial communication.
Interrupt register:
• 8051 µ C has 2 8-bit interrupt register.
Interrupt enable register (IE): It is 8-bit register.
• It is bit/byte addressable.
• Its address is A8H.
• It is used to enable and disable function of interrupt.
Interrupt priority register (IP):
• It is 8-bit register.
• It is bit/byte addressable.
• Its address is B8H.
• It is used to select low or high level priority of each
individual interrupts.
Power control register (PCON):

• It is 8-bit register.
• It is byte addressable . Its address is 87H.
• Its bits are used to control mode of power
saving circuit, either idle or power down mode
and
• also one bit is used to modify baud rate of
serial communication.
Program Status Word
PSW
• It is 8 bit register.

• Its address is D0H and It is bit and byte accessible.

• It has 4 conditional flags or math flags which sets


or resets according to condition of result.

It has 3 control flags, by setting or resetting bit


required operation or function can be achieved.
FLAG:

Carry Flag(CY): During addition and subtraction any carry or borrow is


generated then

• carry flag is set otherwise carry flag resets.

• It is used in arithmetic, logical, jump, rotate and Boolean operations.

Auxiliary carry flag(AC): If during addition and subtraction any carry or


borrow is generated from lower 4 bit to higher 4 bit then AC sets else it
resets.
• It is used in BCD arithmetic operations.
FLAG:
Overflow flag(OV): If in signed arithmetic operations result
exceeds more than 7 bit than

• OV flag sets else resets.

• It is used in signed arithmetic operations only.


Parity flag(P): If in result, even no. Of ones "1" are present
than it is called even parity and parity flag sets. In result
odd no. Of ones "1"are present than it is called odd parity
and parity flag resets.
FLAG:
CONTROL FLAGS:

FO: It is user defined flag. The user defines the


function of this flag. The user can set test and
clear this flag through software.
RS1 and RS0: These flags are used to select bank
of register by resetting those flags
Internal Memory
Memory Organization
• The 8051 has two types of memory and these are Program
Memory and Data Memory.

• Program Memory (ROM) is used to permanently save the


program being executed, while Data Memory (RAM) is used for
temporarily storing data and intermediate results created and
used during the operation of the microcontroller.
• Depending on the model in use 8051 microcontroller family in
general have at most a few KB of ROM and 128 or 256 bytes of
RAM is used.
• All 8051 microcontrollers have a 16-bit addressing bus and are
capable of addressing 64 kB memory.
8051 Instructions Set

• The instructions of 8051 can be broadly classified


under the following headings.
• Data transfer instructions
• Arithmetic instructions
• Logical instructions
• Branch instructions
• Subroutine instructions
• Bit manipulation instructions
ADDRESSING MODES
Various methods of accessing the data are called
addressing modes. 8051
addressing modes are classified as follows.
• Immediate AddressingMode
• Register AddressingMode
• Direct AddressingMode
• Register IndirectAddressing Mode
• Indexed AddressingMode
• Implied AddressingMode
Thank You

You might also like