0% found this document useful (0 votes)
32 views42 pages

Unit 2 - Lec 1-Intro, Architect& Memory Organization, Pins

The document provides an introduction to the 8051 microcontroller, detailing its architecture, features, and comparisons with microprocessors. It covers aspects such as memory organization, addressing modes, instruction sets, and assembly language programming examples. The document also includes tables and diagrams to illustrate the microcontroller's components and functionalities.
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)
32 views42 pages

Unit 2 - Lec 1-Intro, Architect& Memory Organization, Pins

The document provides an introduction to the 8051 microcontroller, detailing its architecture, features, and comparisons with microprocessors. It covers aspects such as memory organization, addressing modes, instruction sets, and assembly language programming examples. The document also includes tables and diagrams to illustrate the microcontroller's components and functionalities.
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/ 42

UNIT 2

Introduction to 8051 Microcontroller

1
Unit-4 : Introduction to 8051 Microcontroller
Syllabus Overview

 Comparing microprocessors and microcontrollers


 8051 Micro controller Architecture
Signal Description of 8051
 Memory organization
 Addressing modes of 8051
 Instruction set
 Assembly language program examples in 8051.

2
Microcontroller versus general-purpose Microprocessor

Figure 4–1 Microprocessor System Contrasted With Microcontroller System

 The microprocessor with integrated peripherals is the Micro controller.

 on chip Computer.
3
Microcontrollers for Embedded Systems

Table 1–1 Some Embedded Products using Microcontrollers 4


Block Diagram
External Interrupts

Interrupt 4k 128 bytes Timer 1


Control ROM RAM Timer 2

CPU

OSC Bus
4 I/O Ports Serial
Control

P0 P2 P1 P3 TXD RXD
Addr/Data
5
8051- Architecture

6
Microcontrollers and Embedded Processors

• Choosing a microcontroller

7
Microcontrollers and Embedded Processors
• Criteria for choosing a microcontroller

Table 1–3 Features of the 8051 8


Microcontrollers and Embedded Processors

Table 1–4 Comparison of 8051 Family Members 9


Microcontrollers and Embedded Processors

Table 1–6 Versions of 8051 From Atmel (All ROM Flash)

10
Microcontrollers and Embedded Processors

Table 1–7 Various Speeds of 8051 From Atmel

11
Comparison of microprocessors and microcontrollers
S.No Microprocessor Micro Controller
Microprocessor is heart of Computer Micro Controller is a heart of
1
system. Embedded System.
Micro controller has internal
Memory and I/O components have to
2 processor along with internal memory
be connected externally
and I/O components
Memory and I/O has to be connected Memory and I/O are present
3
externally, the circuit becomes large. internally, the circuit is small.
Cannot be used in compact systems Can be used in compact systems and
4
and hence inefficient hence it is an efficient technique
5 Cost of the entire system high Cost of the entire system is low
Due to external components, the
Since external components are low,
entire power consumption is high.
total power consumption is less and
6 Hence it is not suitable to use with
can be used with devices running on
devices running on stored power like
stored power like batteries.
batteries.

12
Comparison of microprocessors and microcontrollers cont’d…
S.No Microprocessor Micro Controller
Most of the micro controllers have
Most of the microprocessors do not power saving modes like idle mode and
7
have power saving features. power saving mode. This helps to reduce
power consumption even further.
Since memory and I/O components
Since components are internal, most of
are all external, each instruction will
8 the operations are by internal
need external operation, hence it is
instructions, hence speed is fast.
relatively slower.
Microprocessor have less number of Micro controller have more number of
9 registers, hence more operations registers, hence the programs are easier
are memory based. to write.
Microprocessors are based on
Micro controllers are based on Harvard
von Neumann model/architecture
10 architecture where program memory
where program and data are stored
and Data memory are separate.
in same memory module
Used mainly in washing machine, MP3
11 Mainly used in personal computers
players etc.,
13
Features of 8051 Micro Controller:
1. It is 8 bit Micro Controller (8 bit data bus,16 bit address bus).
2. It has on chip oscillator and CLK generator ckt with operating freq.12MHz.
3. It has on chip 4KB ROM which can be expanded up to 64 KB.
4. It has 128 bytes of on chip RAM.
5. It has 4 register banks: bank 0, bank 1, bank 2, and bank 3.
Each register bank consists of 8 registers.
6. The data memory can be expanded up to 64kB.
7. It has 4 parallel I/O port: port0, port1, port2, port3.
Each port is 8-bit directional I/O port. Each port is bit/byte addressable.
8. It has two 16 bit multi mode programmable timer/counter.

14
Features of 8051 Micro Controller: cont’d…

It has multi mode high speed programmable full duplex serial port.
0. It has 5 Hardware interrupts:
internal interrupts: 3 and
external interrupts: 2
1. All 5 interrupt are operated in two priority level.
2. It has on chip power saving circuit operated in two modes:
1. Idle mode 2. Power down mode.
3. It has 11 special function register.
4. It has 111 instructions, 64 instructions are single cycle.
5. It has on chip Boolean processor for single bit manipulation.

15
8051- Architecture

16
8051- Architecture

17
8051- Architecture cont’d…

Oscillator and clock generator:

 All operations in a microcontroller are synchronized by an oscillator clock.


 A resonant network connected through pins XTAL1 and XTAL2 forms up an
oscillator.
 For this purpose a quartz crystal and capacitors are employed.
 The crystal run at specified maximum and minimum frequencies typically
at 1 MHz to 16 MHz

C2
XTAL2
30pF
C1
XTAL1
30pF
GND
18
8051- Architecture cont’d…
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.
 It consists of Boolean processor which performs bit, set, test and clear.
 8051 micro controller contains 34 general purpose registers or
working registers.
 2 of them are called math registers A & B and 32 are bank of registers.

19
8051- Architecture cont’d…

A Register (Accumulator): -

• The A (accumulator) register is the most versatile of the two CPU registers.
• It is used for many operations, including addition, subtraction,
integer multiplication and division and Boolean bit manipulations.
• The A register is also used for all data transfers between the 8051 and
any external memory.

B Register: -

• The B register is used with the A register for multiplication and division
operations and has no other function other than as a location where
data may be stored.

20
8051- Architecture cont’d…

Program Status Word Register (PSW): -


It contains several status bits that reflect the current state of the CPU.

• This register contains four mathematical flags


1. Carry flag, 2. Auxiliary Carry,
3. Overflow flag, 4. Parity bit

• two register bank select bits (RS1 & RS0),

• one user-definable status flag (F0) and

• one bit is not defined.


21
22
8051- Architecture cont’d…

Program Status Word Register (PSW): -


P - Parity bit: -
odd parity-set even parity-reset
• If a number stored in the accumulator A contains odd no. of 1’s then this bit
will be automatically set (1), otherwise it will be cleared (0).
• It is mainly used during data transmit and receive via serial communication.

OV - Overflow: -

• Overflow occurs when the result of an arithmetical operation is larger than


255 and cannot be stored in one register.
• Overflow condition causes the OV bit to be set (1) , otherwise,
it will be cleared (0). 23
8051- Architecture cont’d…

Program Status Word Register (PSW): -

RS0, RS1 - Register bank select bits.


• These two bits are used to select one of four register banks of RAM.
• By setting and clearing these bits, registers R0-R7 are stored in one
of four banks of RAM.

RS1 RS0 Space in RAM


0 0 Bank0 (00H-07H)
0 1 Bank1 (08H-0FH)
1 0 Bank2 (10H-17H)
1 1 Bank3 (18H-1FH)

F0 – User Flag 0.
This is a general-purpose user defined flag the use of this flag is decided by
the user. 24
8051- Architecture cont’d…

Program Status Word Register (PSW): -

AC - Auxiliary Carry Flag: -

• It is used for BCD operations only.


• This flag is set to ‘1’ when in the addition operation the carry is generated
at bit position D3 or in subtraction operation borrow is needed at the
bit position D3.

CY - Carry Flag: -

• This flag is set to ‘1’ when in the addition operation the final carry is
generated or in subtraction operation the Minuend is less than the
Subtrahend.

25
8051- Architecture cont’d…

Program counter(PC):

 The Program Counter (PC) is a 2-byte address register 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.

 When the 8051 is initialized, PC always starts at 0000h and is


incremented each time an instruction is executed.

 It is important to note that PC is always incremented by one and


never decremented.

26
8051- Architecture cont’d…
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.


 It is divided into two 8-bit registers,
DPH-data pointer higher order (83H) and
DPL -data pointer lower order(82H).

 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


indirect jump. 27
8051- Architecture cont’d…

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 address , which are
used as stack memory.

 When the data is to be placed on stack by push instruction, the content


of SP is incremented by 1.

 When data is retrieved from stack, content of SP is decremented by 1.

28
8051- Architecture cont’d…

Special function Registers(SFR):

1. Timer/Counter register : Timer-reg-T0 ; Timer/counter Reg-T1

Timer control register : TMOD and TCON .


TMOD: Timer Mode
TCON: Timer Control
2. Serial data register:
Serial buffer register (SBUF)
Serial control register (SCON)

3. Interrupt register:
interrupt priority register (IP)
interrupt enable register (IE)

4. Power control register (PCON) 29


8051- Architecture cont’d…
Memory Organization:

Internal Memory:

The 8051 μC has internal program memory (ROM-4kB) and


internal data memory (RAM-128bytes).

Internal RAM: -
 The 8051 microcontroller has 128 bytes of internal RAM.
 Its address range from 00H to 07FH.
 From 80H to 0FFH address space are assigned to SFRs (Special Function
Registers).
 The internal RAM 128Bytes can divide into three parts. Those are

1. Register Banks – 32 Bytes (00H – 1FH)


2. Bit/Byte addressable memory – 16 Bytes (20H – 2FH)
3. User memory or General purpose memory—80 Bytes (30H – 7FH)
30
8051- Architecture cont’d…
Internal RAM organization:

31
Bit Addressable Registers

Bit Addressable Registers means


to these registers a byte address is allotted for the entire register and
each and every individual bit also have their own address.
We can call these register bits individually by their bit addresses as well as
register byte addresses.

32
8051- Architecture cont’d…

Internal ROM: -

 The 8051 microcontroller has an internal ROM of 4Kbytes


 its addresses from 0000H to 0FFFH.
This is used to store the system files or system code information.

 The program addresses higher than the 0FFFH, which exceeds the
internal ROM capacity, will cause the 8051 to automatically fetch the
Program codes from external program memory.

Code bytes can also be fetched exclusively from the external program
memory addresses from 0000H to FFFFH (64kB), by connecting the
EA (External Active or External Enable) pin to the ground.

33
8051- Architecture cont’d…

ROM Organization: -

• DPTR is used to access external data memory (External RAM)

• PSEN is used to access external program memory (External ROM)


34
Register Name Function Internal Address in Hex
A Accumulator * 0E0H
SFRs B Arithmetic * 0F0H
DPL Data Pointer Lower 82H
80H to DPH Data Pointer Higher 83H
0FFH SP
TCON
Stack Pointer
Timer Control Register *
81H
88H
TMOD Timer Mode Register 89H
SCON Serial Control Register * 98H
SBUF Serial Buffer Register 99H
PCON Power Control Register 87H
IP Interrupt Priority Register * 0A8H
IE Interrupt Enable Register * 0B8H
PORT 0 Input/output Port Latch – 0 * 80H
PORT 1 Input/output Port Latch – 1 * 90H
PORT 2 Input/output Port Latch – 2 * 0A0H
PORT 3 Input/output Port Latch – 3 * 0B0H
TL0 Timer - 0 Lower 8AH
TH0 Timer - 0 Higher 8CH
TL1 Timer - 1 Lower 8BH
TH0 Timer - 1 Higher 8DH
PSW Program Status Word * 0D0H

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

36
PINS of 8051 (IO Ports)

• One of the most useful features of the 8051 is that it contains four I/O
ports (P0 - P3)

• Port 0 ( pins 32-39 ): P0 ( P0.0 ~ P0.7 )


– 8-bit R/W - General Purpose I/O
– Or acts as a multiplexed low byte address and data bus for external
memory design

• Port 1 ( pins 1-8 ) : P1 ( P1.0 ~ P1.7 )


– Only 8-bit R/W - General Purpose I/O

• Port 2 ( pins 21-28 ): P2 ( P2.0 ~ P2.7 )


– 8-bit R/W - General Purpose I/O
– Or high byte of the address bus for external memory design

• Port 3 ( pins 10-17 ): P3 ( P3.0 ~ P3.7 )


– General Purpose I/O
– if not using any of the internal peripherals (timers) or external interrupts.

• Each port can be used as input or output (bi-directional)

37
Port 3 Alternate Functions

38
Pins of 8051 cont’d…

• PSEN (out): Program Store Enable, the read signal for


external program memory (active low).
• ALE (out): Address Latch Enable, to latch address outputs
at Port0 and Port2
• EA (in): External Access Enable, active low to access
external program memory locations 0 to 4K
• RXD,TXD: UART pins for serial I/O on Port 3
• XTAL1 & XTAL2: Crystal inputs for internal oscillator.

39
Pins of 8051 cont’d…

• Vcc ( pin 40 ):
– Vcc provides supply voltage to the chip.
– The voltage source is +5V.

• GND ( pin 20 ): ground

• XTAL1 and XTAL2 ( pins 19,18 ):

– These 2 pins provide external clock.


– Way 1 : using a quartz crystal oscillator
– Way 2 : using a TTL oscillator
40
Pins of 8051 cont’d…

• RST ( pin 9 ): reset


– input pin and active high ( normally low ) .
• The high pulse must be high at least 2 machine
cycles.
– power-on reset.
• 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

41
RESET Value of Some 8051 Registers:

Register Reset Value

PC 0000

ACC 0000

B 0000

PSW 0000

SP 0007

DPTR 0000

RAM are all zero

You might also like