0% found this document useful (0 votes)
7 views101 pages

Module-1 1

The document provides an overview of microcontrollers, specifically focusing on the 8051 microcontroller architecture, its components, and functionalities. It details the differences between microprocessors and microcontrollers, outlines the 8051 instruction set, and describes interfacing with external devices. Additionally, it covers programming aspects, including assembly language examples and the use of various registers within the 8051 architecture.

Uploaded by

Raja G V
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)
7 views101 pages

Module-1 1

The document provides an overview of microcontrollers, specifically focusing on the 8051 microcontroller architecture, its components, and functionalities. It details the differences between microprocessors and microcontrollers, outlines the 8051 instruction set, and describes interfacing with external devices. Additionally, it covers programming aspects, including assembly language examples and the use of various registers within the 8051 architecture.

Uploaded by

Raja G V
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/ 101

Module No: 1

8051
Microcontroller
● Introduction
II

18EC4
6
Micocontroll
MICROCONTROLLER 18EC46

AVR: Advanced Virtual RISC


PIC: Programmable Interface Controller

Halesha H R
MICROCONTROLLER 18EC46

Definition:
• Microcontroller (MCU for microcontroller unit) is a small computer on a
single metal-oxide-semiconductor (MOS) integrated circuit (IC) chip.
• Microcontroller contains one or more CPUs (processor cores) along with
memory and programmable input/output peripherals.

Halesha H R
MICROCONTROLLER 18EC46

Halesha H R
MICROCONTROLLER 18EC46

Halesha H R
MICROCONTROLLER 18EC46

Halesha H R
MICROCONTROLLER Syllabus 18EC46
Module -2
Module-1
8051 Instruction Set: Addressing Modes, Data
8051 Microcontroller: Microprocessor Vs
Transfer instructions, Arithmetic instructions,
Microcontroller, Embedded Systems, Embedded
Logical instructions, Branch instructions, Bit
Microcontrollers, 8051 Architecture- Registers,
manipulation instructions. Simple Assembly
Pin diagram, I/O ports functions, Internal
language program examples (without loops) to
Memory organization. External Memory (ROM &
use these instructions.
RAM) interfacing.

Module-3
8051 Stack, I/O Interfacing
Programming: and
Port8051 Stack, Stack and Subroutine
instructions. Assembly language program
examples on subroutine and involving loops.
Interfacing simple switch and LED to I/O ports to
switch on/off LED with respect to switch status.

Halesha H R
MICROCONTROLLER Syllabus 18EC46

Module -4 Module -5
8051 Timers and Serial Port: 8051 Timers and 8051 Interrupts and Interfacing Applications:
Counters – Operation and Assembly language 8051 Interrupts. 8051 Assembly language
programming to generate a pulse using Mode-1 programming to generate an external interrupt
and a square wave using Mode-2 on a port pin. using a switch, 8051 C programming to generate a
8051 Serial Communication- Basics of Serial square waveform on a port pin using a Timer
Data Communication, RS-232 standard, 9 pin interrupt. Interfacing 8051 to ADC-0804, DAC, LCD
RS232 signals, Simple Serial Port programming and Stepper motor and their 8051 Assembly
in Assembly and C to transmit a message and to language interfacing programming.
receive data serially.

Halesha H R
MICROCONTROLLER 18EC46

8051 Microcontroller: Microprocessor Vs Microcontroller, Embedded


Systems, Embedded Microcontrollers, 8051 Architecture- Registers, Pin
diagram, I/O ports functions, Internal Memory organization.
External Memory (ROM & RAM) interfacing. L1, L2

Halesha H R
MICROCONTROLLER 18EC46
Computer:
• Computer hardware consists of four main
• Multipurpose programmable machine;
components.
• Reads binary instructions from its memory, 1. Central processing unit (CPU) which acts
• Accepts binary data as input, as computer‘s brain.
• Processes data according to those instructions 2. Input unit through which program and
data can be entered.
and
Eg: Keyboard, Mouse
• Provides results as output. 3. Output unit on which results of the
• Made up of both hardware and software. computations can be displayed.
• Hardware: Various components of the computer. Eg: Monitor

• Software: Set of instructions written for computer to 4. Memory in which data and programs are
stored.
solve a specific task is called program and collection of
programs is called software.

Halesha H R
MICROCONTROLLER 18EC46
Computer:

Fig: Block Diagram of a


Microcomputer.

Halesha H R
MICROCONTROLLER 18EC46
Microprocessors:
• Used as digital computer central processing unit (CPU).
• Known as ‘Computer on Chip’ but not complete digital
computer.
• Block diagram of a Microprocessor CPU consists of:
• ALU, Program counter (PC), Stack pointer (SP),
working registers, clock timing circuit and interrupt
circuit’s.
• For microcomputer we must add;
• Memory usually RAM and ROM, memory decoders,
oscillator & number of Input/Output devices such as Fig: Block Diagram of a
serial and parallel ports. Microprocessor.
• In addition special purpose devices such as interrupt
handler and counters may be added to relieve the
CPU from time consuming.

Halesha H R
MICROCONTROLLER 18EC46
Microcontroller:
• Microcontroller is a programmable digital processor with necessary peripherals.
• Both microcontrollers and microprocessors are complex sequential digital circuits
meant to carry out job according to the program/instructions.
• Analog input/output interface makes a part of microcontroller circuit as mixed mode
(both analog and digital) in nature.
• Microcontroller is a true “Computer on chip”.
• Incorporates all features found in microprocessor CPU: ALU, PC, SP and registers.
• Also has other features needed to make a complete computer: ROM, RAM, Parallel I/O,
serial I/O, Counters and clock circuits.

Halesha H R
MICROCONTROLLER 18EC46
Microcontroller:

Fig: Block Diagram of a Microcontroller

Halesha H R
MICROCONTROLLER 18EC46
Differences Between Microprocessor & Microcontroller
Microprocessor: Microcontroller:
1. CPU is stand-alone. RAM, ROM, I/O, timer are 1. CPU, RAM, ROM, I/O, and timer are located on a
separate and interfaced with CPU. single chip.
2. Designer can decide on the amount of RAM, 2. Fixed amount of RAM, ROM, I/O ports on chip.
ROM etc can be connected. 3. Applications in which cost, space and power
3. Expensive applications. are critical.
4. Versatile and general purpose. 4. Not very versatile.
5. Large number of instructions with flexible 5. Limited number of instructions with few
addressing modes. addressing modes.
6. Very few instructions 6. Many instructions which have bit-
which have bit-handling handling
capability.
capability.
Halesha H R
Module No: 1

8051 Microcontroller
● 8051 Architecture,
Registers
II

18EC4
6
Micocontroll
MICROCONTROLLER 18EC46
8051 Microcontroller:
Definition: It is an 8-bit microcontroller created in 1981
by Intel Corporation. It has an 8-bit processor that
means it operates on 8-bit data at a time. It is the most
popular and commonly used microcontroller.
• It is 40-pin IC
• Data bus is 8-bit

Halesha H R
MICROCONTROLLER Architecture of 8051 18EC46
Arithmetic & Arithmetic and Logic Unit:
Logic Unit • Its an 8-bit
• Performs arithmetic and logical operations on 8-bit data.

Halesha H R
MICROCONTROLLER Architecture of 8051 18EC46
Arithmetic &
A and B registers:
Logic Unit
• 8-bit registers, holds result of arithmetic and logical operations.
A B • Bit-addressable registers i.e., each bit can be accessed for reading or
for altering.
• A register is also called as Accumulator, since it is used as destination
in many operations such as addition, subtraction, integer
multiplication, division, Boolean bit manipulation and Accumulates
the result.
• Also used for data transfers between 8051 and external memory.

Halesha H R
MICROCONTROLLER Architecture of 8051 18EC46
Arithmetic &
A and B registers:
Logic Unit
• B register may be used as general purpose register to store the data.
A B • Along with A register, B register is used for multiplication and division
operations.

Halesha H R
MICROCONTROLLER Architecture of 8051 18EC46
Arithmetic &
PSW
Program Status Word (PSW) Register:
Logic Unit
• 8-bit register, also referred to as flag register.

A B • Indicates certain conditions like carry, parity, sign etc. after execution
of certain instructions.

• These conditions are indicated by flags.

• Flags are 1-bit registers, jump instructions can test condition of flags
(0 or 1) and make decisions based on status of flags.

Halesha H R
MICROCONTROLLER Architecture of 8051 18EC46
Arithmetic &
PSW
Program Status Word (PSW) Register:
Logic Unit
• Status of flags are grouped in PSW register, Only 6 bits are used.

A B • Two unused bits are user definable flags.

• Four flags are called conditional flags, indicates conditions after


execution of certain instructions.

• CY (carry), AC (auxiliary carry), P (parity), & OV (overflow).

Halesha H R
MICROCONTROLLER Architecture of 8051 18EC46
Arithmetic &
PSW
Program Status Word (PSW) Register:
Logic Unit • PSW and bit assignments are shown below:
7 6 5 4 3 2 1 0
A B CY AC F0 RS1 RS0 OV -- P
CY: Carry Flag
• Alternate name is PSW.7
• Used in arithmetic, jump, rotate, and Boolean instructions
= 1; when there is a carry after an addition or a barrow after
subtraction.
= 0; otherwise
• Also it can be set or reset using an instructions “SETB C” &
“CLR C”.

Halesha H R
MICROCONTROLLER Architecture of 8051 18EC46
Arithmetic &
PSW
Program Status Word (PSW) Register:
Logic Unit • PSW and bit assignments are shown below:
7 6 5 4 3 2 1 0
A B CY AC F0 RS1 RS0 OV -- P

AC: Auxiliary carry flag


• Alternate name is PSW.6
• Used for BCD arithmetic.
= 1; when there is a carry from lower nibble to upper nibble or
barrow from upper nibble to lower nibble.
= 0; otherwise
• Used by the instructions that perform BCD arithmetic.

Halesha H R
MICROCONTROLLER Architecture of 8051 18EC46
Arithmetic &
PSW
Program Status Word (PSW) Register:
Logic Unit • PSW and bit assignments are shown below:
7 6 5 4 3 2 1 0
A B CY AC F0 RS1 RS0 OV -- P

Example:
Bit No: 7 6 5 4 3 2 1 0

1 0 0 1 1 0 0 0 = 98h
1 0 0 0 1 0 0 0 = 88h

Halesha H R
MICROCONTROLLER Architecture of 8051 18EC46
Arithmetic &
PSW
Program Status Word (PSW) Register:
Logic Unit • PSW and bit assignments are shown below:
7 6 5 4 3 2 1 0
A B CY AC F0 RS1 RS0 OV -- P

Example:
Bit No: 7 6 5 4 3 2 1 0

1 0 0 1 1 0 0 0 = 98h
1 0 0 0 1 0 0 0 = 88h
0

Halesha H R
MICROCONTROLLER Architecture of 8051 18EC46
Arithmetic &
PSW
Program Status Word (PSW) Register:
Logic Unit • PSW and bit assignments are shown below:
7 6 5 4 3 2 1 0
A B CY AC F0 RS1 RS0 OV -- P

Example:
Bit No: 7 6 5 4 3 2 1 0

1 0 0 1 1 0 0 0 = 98h
1 0 0 0 1 0 0 0 = 88h
0 0

Halesha H R
MICROCONTROLLER Architecture of 8051 18EC46
Arithmetic &
PSW
Program Status Word (PSW) Register:
Logic Unit • PSW and bit assignments are shown below:
7 6 5 4 3 2 1 0
A B CY AC F0 RS1 RS0 OV -- P

Example:
Bit No: 7 6 5 4 3 2 1 0

1 0 0 1 1 0 0 0 = 98h
1 0 0 0 1 0 0 0 = 88h
0 0 0

Halesha H R
MICROCONTROLLER Architecture of 8051 18EC46
Arithmetic &
PSW
Program Status Word (PSW) Register:
Logic Unit • PSW and bit assignments are shown below:
7 6 5 4 3 2 1 0
A B CY AC F0 RS1 RS0 OV -- P

Example:
Bit No: 7 6 5 4 3 2 1 0

1 0 0 1 1 0 0 0 = 98h
1 0 0 0 1 0 0 0 = 88h
0 0 0 0

Halesha H R
MICROCONTROLLER Architecture of 8051 18EC46
Arithmetic &
PSW
Program Status Word (PSW) Register:
Logic Unit • PSW and bit assignments are shown below:
7 6 5 4 3 2 1 0
A B CY AC F0 RS1 RS0 OV -- P

Example:
Bit No: 7 6 5 4 3 2 1 0
AC = 1
1 0 0 1 1 0 0 0 = 98h
1 0 0 0 1 0 0 0 = 88h
0 0 0 0

Halesha H R
MICROCONTROLLER Architecture of 8051 18EC46
Arithmetic &
PSW
Program Status Word (PSW) Register:
Logic Unit • PSW and bit assignments are shown below:
7 6 5 4 3 2 1 0
A B CY AC F0 RS1 RS0 OV -- P

Example:
Bit No: 7 6 5 4 3 2 1 0
AC = 1
1 0 0 1 1 0 0 0 = 98h
1 0 0 0 1 0 0 0 = 88h
0 0 0 0 0

Halesha H R
MICROCONTROLLER Architecture of 8051 18EC46
Arithmetic &
PSW
Program Status Word (PSW) Register:
Logic Unit • PSW and bit assignments are shown below:
7 6 5 4 3 2 1 0
A B CY AC F0 RS1 RS0 OV -- P

Example:
Bit No: 7 6 5 4 3 2 1 0
1 AC = 1
1 0 0 1 1 0 0 0 = 98h
1 0 0 0 1 0 0 0 = 88h
0 0 0 0 0

Halesha H R
MICROCONTROLLER Architecture of 8051 18EC46
Arithmetic &
PSW
Program Status Word (PSW) Register:
Logic Unit • PSW and bit assignments are shown below:
7 6 5 4 3 2 1 0
A B CY AC F0 RS1 RS0 OV -- P

Example:
Bit No: 7 6 5 4 3 2 1 0
1 AC = 1
1 0 0 1 1 0 0 0 = 98h
1 0 0 0 1 0 0 0 = 88h
1 0 0 0 0 0

Halesha H R
MICROCONTROLLER Architecture of 8051 18EC46
Arithmetic &
PSW
Program Status Word (PSW) Register:
Logic Unit • PSW and bit assignments are shown below:
7 6 5 4 3 2 1 0
A B CY AC F0 RS1 RS0 OV -- P

Example:
Bit No: 7 6 5 4 3 2 1 0
1 AC = 1
1 0 0 1 1 0 0 0 = 98h
1 0 0 0 1 0 0 0 = 88h
0 1 0 0 0 0 0

Halesha H R
MICROCONTROLLER Architecture of 8051 18EC46
Arithmetic &
PSW
Program Status Word (PSW) Register:
Logic Unit • PSW and bit assignments are shown below:
7 6 5 4 3 2 1 0
A B CY AC F0 RS1 RS0 OV -- P

Example:
Bit No: 7 6 5 4 3 2 1 0
C6 = 0 1 AC = 1
1 0 0 1 1 0 0 0 = 98h
1 0 0 0 1 0 0 0 = 88h
0 1 0 0 0 0 0

Halesha H R
MICROCONTROLLER Architecture of 8051 18EC46
Arithmetic &
PSW
Program Status Word (PSW) Register:
Logic Unit • PSW and bit assignments are shown below:
7 6 5 4 3 2 1 0
A B CY AC F0 RS1 RS0 OV -- P

Example:
Bit No: 7 6 5 4 3 2 1 0
C6 = 0 1 AC = 1
1 0 0 1 1 0 0 0 = 98h
1 0 0 0 1 0 0 0 = 88h
0 0 1 0 0 0 0 0

Halesha H R
MICROCONTROLLER Architecture of 8051 18EC46
Arithmetic &
PSW
Program Status Word (PSW) Register:
Logic Unit • PSW and bit assignments are shown below:
7 6 5 4 3 2 1 0
A B CY AC F0 RS1 RS0 OV -- P

Example:
Bit No: 7 6 5 4 3 2 1 0
C7 = 1 C6 = 0 1 AC = 1
1 0 0 1 1 0 0 0 = 98h
1 0 0 0 1 0 0 0 = 88h
0 0 1 0 0 0 0 0

Halesha H R
MICROCONTROLLER Architecture of 8051 18EC46
Arithmetic &
PSW
Program Status Word (PSW) Register:
Logic Unit • PSW and bit assignments are shown below:
7 6 5 4 3 2 1 0
A B CY AC F0 RS1 RS0 OV -- P

Example:
Bit No: 7 6 5 4 3 2 1 0
C7 = 1 C6 = 0 1 AC = 1
1 0 0 1 1 0 0 0 = 98h
1 0 0 0 1 0 0 0 = 88h
0 0 1 0 0 0 0 0 = 20h

Halesha H R
MICROCONTROLLER Architecture of 8051 18EC46
Arithmetic &
PSW
Program Status Word (PSW) Register:
Logic Unit • PSW and bit assignments are shown below:
7 6 5 4 3 2 1 0
A B CY AC F0 RS1 RS0 OV -- P

F0: General purpose user flag


• Alternate name is PSW.5
• Used for general purpose

Halesha H R
MICROCONTROLLER Architecture of 8051 18EC46
Arithmetic &
PSW
Program Status Word (PSW) Register:
Logic Unit • PSW and bit assignments are shown below:
7 6 5 4 3 2 1 0
A B CY AC F0 RS1 RS0 OV -- P

OV: Overflow Flag


• Alternate name is PSW.2
• Used in arithmetic instructions.
= 1; when the result of signed operation is too large
= 0; otherwise
• For 8-bit number:
• Range of signed number is: -128 to 127
• Range of unsigned number is: 0 to 255

Halesha H R
MICROCONTROLLER Architecture of 8051 18EC46
Arithmetic &
PSW
Program Status Word (PSW) Register:
Logic Unit • PSW and bit assignments are shown below:
7 6 5 4 3 2 1 0
A B CY AC F0 RS1 RS0 OV -- P

Example:
Bit 6 5 4 3 2 1 0
7
No:
C7 = 1 C6 = 0 1 AC = 1
1 0 0 1 1 0 0 0 = 98h = 152
1 0 0 0 1 0 0 0 = 88h = 136
0 0 1 0 0 0 0 0 = 120h = 288

Halesha H R
MICROCONTROLLER Architecture of 8051 18EC46
Arithmetic &
PSW
Program Status Word (PSW) Register:
Logic Unit • PSW and bit assignments are shown below:
7 6 5 4 3 2 1 0
A B CY AC F0 RS1 RS0 OV -- P

OV: Overflow Flag


• In general, carry flag is used to detect errors in unsigned
arithmetic operations.
• Overflow flag is used to detect errors in signed arithmetic
operations.

Halesha H R
MICROCONTROLLER Architecture of 8051 18EC46
Arithmetic &
PSW
Program Status Word (PSW) Register:
Logic Unit • PSW and bit assignments are shown below:
7 6 5 4 3 2 1 0
A B CY AC F0 RS1 RS0 OV -- P
-- : User defined flag
• Alternate name is PSW.1
• Reserved for future use
P: Parity Flag
• Alternate name is PSW.0
• Shows the parity of register A
• Reflects number of 1’s in accumulator register
= 1; Odd parity: odd number of 1’s
= 0; Even parity: even number of 1’s
Halesha H R
MICROCONTROLLER Architecture of 8051 18EC46
Arithmetic &
PSW
Program Status Word (PSW) Register:
Logic Unit • PSW and bit assignments are shown below:
7 6 5 4 3 2 1 0
A B CY AC F0 RS1 RS0 OV -- P

RS1: Register Select Bit-1; PSW.4


RS0: Register Select Bit-0; PSW.3
• Select register bank as shown
below:
RS1 RS0 Function Address
0 0 Register Bank 0 00h – 07h
0 1 Register Bank 1 08h – 0Fh
1 0 Register Bank 2 10h – 17h
1 1 Register Bank 3 18h – 1Fh
• Default register bank 0 is selected.
Halesha H R
MICROCONTROLLER Architecture of 8051 18EC46
Arithmetic &
PSW Program Counter (PC):
Logic Unit
• 16-bit register, holds address of next instruction to be executed.

A B • Opcodes are fetched from memory addressed by PC. After that, PC is


automatically incremented to point next instruction.
• In 8051, on chip ROM is 4K bytes, addresses from 0000h to 0FFFh.
DPTR • Since PC is 16-bits wide, 8051 can access programs from 0000h to
PC DPL
DPH FFFFh, total of 64K bytes.
• If memory exceeds 0FFFh, memory chip has to be externally interfaced.
• Contents of PC may be altered by instructions CALL, RET etc.
• It is the only register does not have an internal address.
• By de-fault PC is set to 0000h on reset of the microcontroller.
• It expects opcode of first instruction to be stored at ROM address
0000h. Halesha H R
MICROCONTROLLER Architecture of 8051 18EC46
Arithmetic &
PSW Data Pointer (DPTR):
Logic Unit
• 16-bit register, made up of two 8-bit registers called DPH (High) and
A B DPL (Low).
• Index register provides access to external memory.
• DPH and DPL hold the high order byte and low order bye of the
DPTR
DPL address.
PC
DPH • It can be specified as a 16-bit register, or it can be individually specified
as an 8-bit register (DPL or DPH).
• Does not have a single internal address. DPH and DPL are assigned
internal addresses separately (DPH – 83h, DPL – 82h).

Halesha H R
MICROCONTROLLER Architecture of 8051 18EC46
Arithmetic &
PSW Special Special Function Registers (SFR):
Logic Unit Function • Do not use RAM addresses 00h to 7Fh, specific
Register internal registers, uses addresses from 80h to FFh.
A B RAM • Some SFRs are bit-addressable.
• All addresses from 80h to FFh are not used.
• In instructions, SFRs are named by functional
names, such as A or TH0, also referenced by their
DPTR
addresses, such as 0E0h or 8Ch.
PC DPL
• SFR’s have special roles in 8051.
DPH
• Various registers and their addresses are:

Halesha H R
MICROCONTROLLER Architecture of 8051 18EC46
Arithmetic & Special Name: Function: Address
PSW
Logic Unit Function A Accumulator E0
B Arithmetic F0
Register
DPH Addressing External Memory 83
A B RAM DPL Addressing External Memory 82
IE Interrupt Enable Control A8
IP Interrupt Priority B8
P0 Input / Output Port Latch 80
P1 Input / Output Port Latch 90
DPTR P2 Input / Output Port Latch A0
PC DPL P3 Input / Output Port Latch B0
DPH PCON Power Control 87
PSW Program Status Word D0
SCON Serial Port Control 98
SBUF Serial Port Data Buffer 99
SP Stack Pointer 81
TMOD Timer/Counter Mode Control 89
TCON Timer/Counter Control 88
TL0 Timer 0 low byte 8A
TH0 Timer 0 high byte 8C
TL1 Timer 1 low byte 8B
Halesha HTH1
R Timer 1 high byte 8D
MICROCONTROLLER Architecture of 8051 18EC46
Arithmetic &
PSW Special ROM:
Logic Unit Function • 4K bytes of Read only Memory
Register • Address Range: 0000h to 0FFFh
A B RAM

DPTR
PC DPL ROM
DPH

Halesha H R
MICROCONTROLLER Architecture of 8051 18EC46
Arithmetic & Special
PSW
Logic Unit

Port 0
Latch
Function
Register
A B RAM

Port 1
Latch
I/O
DPTR
PC DPL ROM
DPH

Port 2
Latch
I/O Port:
• 32 I/O Pins arranged as 4, 8-Bit
ports

Port 3
Latch
Halesha H R
MICROCONTROLLER Architecture of 8051 18EC46
Arithmetic & Special
PSW
Logic Unit

Port 0
Latch
Function
Register
A B RAM
8-Bit Data &
Address

Port 1
Latch
Bus
I/O
DPTR
PC DPL ROM
DPH 16-Bit

Port 2
Latch
Address Bus

Port 3
Latch
Halesha H R
MICROCONTROLLER Architecture of 8051 18EC46
Arithmetic & Special
PSW
Logic Unit

Port 0
Latch
Function
Register
A B RAM
8-Bit Data &
Address

Port 1
Latch
Bus
I/O
DPTR
PC DPL ROM
DPH 16-Bit

Port 2
Latch
Address Bus

Port 3
Latch
Halesha H R
MICROCONTROLLER Architecture of 8051 18EC46
Arithmetic & Special
PSW
Logic Unit

Port 0
Latch
Function
Register
A B RAM
8-Bit Data &
Address

Port 1
Latch
Bus
I/O
DPTR
PC DPL ROM
DPH 16-Bit

Port 2
Latch
Address Bus

Port 3
Latch
Halesha H R
MICROCONTROLLER Feature of 8051 18EC46

Halesha H R
MICROCONTROLLER Feature of 8051 18EC46
1. 8-bit CPU with registers A (Accumulator) and B. Accumulator is used in most arithmetic and
logic operations. Register B is used for integer multiplication and division.
2. 16-bit Program counter (PC): To hold the address of the next instruction to be executed, and
16-bit Data Pointer (DPTR): Used to access external memory.
3. 8-bit Program Status Word (PSW): Indicates certain conditions like status of carry, parity, sign
etc, after execution of some instructions.
4. 8-bit Stack Pointer (SP): To hold the address of Top of Stack (TOS).
5. Internal Memory (RAM) of 128 bytes, divided as:
i. Four register banks of 8 registers each.
ii. 16 bytes, which are bit addressable. The individual bits of these bytes cab be altered.
iii. 80 bytes of general purpose RAM memory.
iv. 4K Code Memory

Halesha H R
MICROCONTROLLER Feature of 8051 18EC46
6. 4K Code Memory
7. 32 I/O Pins arranged as 4, 8 Bit ports
8. Two 16 Bit Timer/Counter: Timer 0 (T0), and Timer 1 (T1). The timers can be used in timer
mode when counting the internal clock pulses and in counter mode when counting the external
pulses.
9. Full Duplex serial data receiver/transmitter register (SBUF). This holds the byte to be
transmitted or the received byte, when serial communication is used.
10. Control Registers: TCON, TMOD, SCON, PCON, IP and IE which controls the operations of the
timers, serial port and interrupts.
11. Two External and Three Internal Interrupt sources. Interrupts are events which interrupt the
normal sequence of execution of instructions.
12. Oscillator and clock circuits

Halesha H R
MICROCONTROLLER 18EC46
Oscillator Circuit and Timing of 8051:
□ Heart of 8051 which generates clock pulses and all internal
operations are synchronized.
□ In most microcontrollers, built-in circuitry allows simple
connection of a crystal or ceramic resonators or an external
clock source. Pins XTAL1 and XTAL2 are provided.
□ Typically, quartz crystal & capacitors are employed.
□ Ceramic resonators
resonators. is low-
□ costpoor frequency stability and accuracy, foralternative
But high-speed
Fig: Crystal or Ceramic Resonator to
data serial communication with other systems.
crystal
Oscillator Circuit. □ Oscillator formed by crystal, capacitors and on-chip inverter
generates a pulse of train at frequency of the crystal.

Halesha H R
MICROCONTROLLER 18EC46
Oscillator Circuit and Timing of 8051:

Halesha H R
MICROCONTROLLER 18EC46
Oscillator Circuit and Timing of 8051:

P1 P2

• Pulse time (P): Smallest interval of time within the microcontroller,


determined Clock frequency ‘f’.

Halesha H R
MICROCONTROLLER 18EC46
Oscillator Circuit and Timing of 8051:

P1 P2 P1 P2 P1 P2 P1 P2 P1 P2 P1
P2

Halesha H R
MICROCONTROLLER 18EC46
Oscillator Circuit and Timing of 8051:

P1 P2 P1 P2 P1 P2 P1 P2 P1 P2 P1
P2

State 1

• State: Basic time interval for discrete operations of microcontroller


such as fetching an opcode byte, decoding an opcode, executing an
opcode, or writing a data.
• Two oscillator pulses define each state.

Halesha H R
MICROCONTROLLER 18EC46
Oscillator Circuit and Timing of 8051:

P1 P2 P1 P2 P1 P2 P1 P2 P1 P2 P1
P2

State 1 State 2 State 3 State 4 State 5 State 6

Halesha H R
MICROCONTROLLER 18EC46
Oscillator Circuit and Timing of 8051:

P1 P2 P1 P2 P1 P2 P1 P2 P1 P2 P1
P2

State 1 State 2 State 3 State 4 State 5 State 6

One Machine Cycle (6 States, 12 pulses)

• Machine Cycle: Smallest interval of time to accomplish any


simple instruction, or part of a complex instruction.
• Made up of six states.
• Instructions may require one, two, or four machine cycles to be
executed, depending on the type of instructions.

Halesha H R
MICROCONTROLLER 18EC46
Oscillator Circuit and Timing of 8051:

P1 P2 P1 P2 P1 P2 P1 P2 P1 P2 P1 P2

State 1 State 2 State 3 State 4 State 5 State 6

One Machine Cycle (6 States, 12 pulses)

ALE
Address Latch Enable (ALE): Used as a timing pulse for external memory access.
Lower order address bus is multiplexed with data bus: AD0 to AD7
ALE = 1; A0 to A7
ALE = 0; D0 to
D7
Halesha H R
MICROCONTROLLER 18EC46
Oscillator Circuit and Timing of 8051:

P1 P2 P1 P2 P1 P2 P1 P2 P1 P2 P1 P2

State 1 State 2 State 3 State 4 State 5 State 6

One Machine Cycle (6 States, 12 pulses)

ALE

Halesha H R
MICROCONTROLLER 18EC46
Oscillator Circuit and Timing of 8051:

P1 P2 P1 P2 P1 P2 P1 P2 P1 P2 P1 P2

State 1 State 2 State 3 State 4 State 5 State 6

One Machine Cycle (6 States, 12 pulses)

ALE

Halesha H R
MICROCONTROLLER 18EC46
Oscillator Circuit and Timing of 8051:

P1 P2 P1 P2 P1 P2 P1 P2 P1 P2 P1 P2

State 1 State 2 State 3 State 4 State 5 State 6

One Machine Cycle (6 States, 12 pulses)

ALE

Halesha H R
MICROCONTROLLER 18EC46
Oscillator Circuit and Timing of 8051:

P1 P2 P1 P2 P1 P2 P1 P2 P1 P2 P1 P2

State 1 State 2 State 3 State 4 State 5 State 6

One Machine Cycle (6 States, 12 pulses)

ALE

• Two byte instructions, can be fetched in the same machine cycle.


• If instructions are one byte, at second ALE pulse, first byte of next
instruction is fetched.
• Later discarded and again fetched in the next machine cycle.
Halesha H R
MICROCONTROLLER 18EC46
Oscillator Circuit and Timing of 8051:

P1 P2 P1 P2 P1 P2 P1 P2 P1 P2 P1 P2

State 1 State 2 State 3 State 4 State 5 State 6

One Machine Cycle (6 States, 12 pulses)

ALE

Address Memory Write ALP to add two numbers stored in 20h & 21h and store the result in 22h.
in Hex ORG 00h
Content MOV A, 20h ;Copy content of 20h into A register, A = 39h
22 5C MOV R0, 21h ;Copy content of 21h into R0 register, R0 = 23h
ADD A, R0 ;Add content of A with the content of R0
21 23 MOV 22h, A ;Store result 20h, 20h = 5Ch
20 39 END ;End of
MICROCONTROLLER 18EC46
Oscillator Circuit and Timing of 8051:

P1 P2 P1 P2 P1 P2 P1 P2 P1 P2 P1
Address P2Memory
in Hex
0006 Content
22
State 1 State 2 State 3 State 4 State 5 State 6
0005 F5
One Machine Cycle (6 States, 12 pulses) 0004 28
0003 21
ALE
0002 A8
Address Memory ORG 00h 0001 20
in Hex MOV A, 20h ;E5h, 20h 0000 E5
Content MOV R0, ;A8h, 21h
22 5C 21h
ADD A, R0 ;28h
MOV 22h, ;F5h, 22h
21 23 A END
20 39 Halesha H R
MICROCONTROLLER 18EC46
Oscillator Circuit and Timing of 8051:

P1 P2 P1 P2 P1 P2 P1 P2 P1 P2 P1 P2

State 1 State 2 State 3 State 4 State 5 State 6

One Machine Cycle (6 States, 12 pulses)

ALE

Halesha H R
MICROCONTROLLER 18EC46
Oscillator Circuit and Timing of 8051:

P1 P2 P1 P2 P1 P2 P1 P2 P1 P2 P1 P2

State 1 State 2 State 3 State 4 State 5 State 6

One Machine Cycle (6 States, 12 pulses)

ALE

Halesha H R
MICROCONTROLLER 18EC46
8051 Internal Memory:
□ Memory is must to store program codes and also data.
□ 8051 has internal ROM (4K byte) and RAM (128 bytes) memory.
□ Harvard architecture: Uses same address in different memory locations for code and data.
□ Additional external memory can be interfaced if required.
□ Internal circuitry accesses correct memory segment, based on the instruction being
executed.

Halesha H R
MICROCONTROLLER 18EC46
8051 Internal RAM Memory: Register Banks:
• Starting 32 bytes from 00h to 1Fh are assigned to 32
□ 128bytes internal
working registers.
RAM is organized into 3
• Organized as 4 register banks, each having 8 registers.
distinct areas. Banks are: Bank 0 to Bank 3
1. Register Banks Registers are: R0 to R7
2. Bit/Byte addressable RAM • Register can be addressed by name or by its address.
3. General purpose RAM • RS0 & RS1 of PSW determines which bank is currently
selected.
• Register banks which are not selected can be used as
general purpose RAM.
• By default Bank 0 is selected on reset.

Halesha H R
MICROCONTROLLER 18EC46
8051 Internal RAM Memory:
Bank 0 Bank 1 Bank 2 Bank 3
Address Address Address Address
in Hex in Hex in Hex in Hex
07 R7 0F R7 17 R7 1F R7
06 R6 0E R6 16 R6 1E R6
05 R5 0D R5 15 R5 1D R5
04 R4 0C R4 14 R4 1C R4
03 R3 0B R3 13 R3 1B R3
02 R2 0A R2 12 R2 1A R2
01 R1 09 R1 11 R1 19 R1
00 R0 08 R0 10 R0 18 R0

Halesha H R
MICROCONTROLLER 18EC46
Address
8051 Internal RAM Memory: in Hex
7 6 5 4 3 2 1 0

Bit/Byte addressable RAM: 2F


2E
• Next 16 bytes from 20h to 2Fh are bit
2D
addressable. 2C

• Total number of bits are 128. 2B


2A
29
28
27
26
25
24
23
22
21

Halesha H R 20
MICROCONTROLLER 18EC46
Address
8051 Internal RAM Memory: in Hex
7 6 5 4 3 2 1 0

Bit/Byte addressable RAM: 2F


2E
• Next 16 bytes from 20h to 2Fh are bit
2D
addressable. 2C

• Total number of bits are 128. 2B


2A
29
28
27
26
25
24
23
22
21

Halesha H R 20 07 06 05 04 03 02 01 00
MICROCONTROLLER 18EC46
Address
8051 Internal RAM Memory: in Hex
7 6 5 4 3 2 1 0

Bit/Byte addressable RAM: 2F


2E
• Next 16 bytes from 20h to 2Fh are bit
2D
addressable. 2C

• Total number of bits are 128. 2B


2A
29
28
27
26
25
24
23
22
21 0F 0E 0D 0C 0B 0A 09 08

Halesha H R 20 07 06 05 04 03 02 01 00
MICROCONTROLLER 18EC46
Address
8051 Internal RAM Memory: in Hex
7 6 5 4 3 2 1 0

Bit/Byte addressable RAM: 2F


2E
• Next 16 bytes from 20h to 2Fh are bit
2D
addressable. 2C

• Total number of bits are 128. 2B


2A
29
28
27
26
25
24
23
22 17 16 15 14 13 12 11 10

21 0F 0E 0D 0C 0B 0A 09 08

Halesha H R 20 07 06 05 04 03 02 01 00
MICROCONTROLLER 18EC46
Address
8051 Internal RAM Memory: in Hex
7 6 5 4 3 2 1 0

Bit/Byte addressable RAM: 2F


2E
• Next 16 bytes from 20h to 2Fh are bit
2D
addressable. 2C

• Total number of bits are 128. 2B


2A
29
28
27
26
25
24
23 1F 1E 1D 1C 1B 1A 19 18

22 17 16 15 14 13 12 11 10

21 0F 0E 0D 0C 0B 0A 09 08

Halesha H R 20 07 06 05 04 03 02 01 00
MICROCONTROLLER 18EC46
Address
8051 Internal RAM Memory: in Hex
7 6 5 4 3 2 1 0

Bit/Byte addressable RAM: 2F


2E
• Next 16 bytes from 20h to 2Fh are bit
2D
addressable. 2C

• Total number of bits are 128. 2B


2A
29
28
27
26
25
24 27 26 25 24 23 22 21 20

23 1F 1E 1D 1C 1B 1A 19 18

22 17 16 15 14 13 12 11 10

21 0F 0E 0D 0C 0B 0A 09 08

Halesha H R 20 07 06 05 04 03 02 01 00
MICROCONTROLLER 18EC46
Address
8051 Internal RAM Memory: in Hex
7 6 5 4 3 2 1 0

Bit/Byte addressable RAM: 2F


2E
• Next 16 bytes from 20h to 2Fh are bit
2D
addressable. 2C

• Total number of bits are 128. 2B


2A
29
28
27
26
25 2F 2E 2D 2C 2B 2A 29 28

24 27 26 25 24 23 22 21 20

23 1F 1E 1D 1C 1B 1A 19 18

22 17 16 15 14 13 12 11 10

21 0F 0E 0D 0C 0B 0A 09 08

Halesha H R 20 07 06 05 04 03 02 01 00
MICROCONTROLLER 18EC46
Address
8051 Internal RAM Memory: in Hex
7 6 5 4 3 2 1 0

Bit/Byte addressable RAM: 2F


2E
• Next 16 bytes from 20h to 2Fh are bit
2D
addressable. 2C

• Total number of bits are 128. 2B


2A
29
28
27
26 37 36 35 34 33 32 31 30

25 2F 2E 2D 2C 2B 2A 29 28

24 27 26 25 24 23 22 21 20

23 1F 1E 1D 1C 1B 1A 19 18

22 17 16 15 14 13 12 11 10

21 0F 0E 0D 0C 0B 0A 09 08

Halesha H R 20 07 06 05 04 03 02 01 00
MICROCONTROLLER 18EC46
Address
8051 Internal RAM Memory: in Hex
7 6 5 4 3 2 1 0

Bit/Byte addressable RAM: 2F


2E
• Next 16 bytes from 20h to 2Fh are bit
2D
addressable. 2C

• Total number of bits are 128. 2B


2A
29
28
27 3F 3E 3D 3C 3B 3A 39 38

26 37 36 35 34 33 32 31 30

25 2F 2E 2D 2C 2B 2A 29 28

24 27 26 25 24 23 22 21 20

23 1F 1E 1D 1C 1B 1A 19 18

22 17 16 15 14 13 12 11 10

21 0F 0E 0D 0C 0B 0A 09 08

Halesha H R 20 07 06 05 04 03 02 01 00
MICROCONTROLLER 18EC46
Address
8051 Internal RAM Memory: in Hex
7 6 5 4 3 2 1 0

Bit/Byte addressable RAM: 2F


2E
• Next 16 bytes from 20h to 2Fh are bit
2D
addressable. 2C

• Total number of bits are 128. 2B


2A
29
28 47 46 45 44 43 42 41 40

27 3F 3E 3D 3C 3B 3A 39 38

26 37 36 35 34 33 32 31 30

25 2F 2E 2D 2C 2B 2A 29 28

24 27 26 25 24 23 22 21 20

23 1F 1E 1D 1C 1B 1A 19 18

22 17 16 15 14 13 12 11 10

21 0F 0E 0D 0C 0B 0A 09 08

Halesha H R 20 07 06 05 04 03 02 01 00
MICROCONTROLLER 18EC46
Address
8051 Internal RAM Memory: in Hex
7 6 5 4 3 2 1 0

Bit/Byte addressable RAM: 2F


2E
• Next 16 bytes from 20h to 2Fh are bit
2D
addressable. 2C

• Total number of bits are 128. 2B


2A
29 4F 4E 4D 4C 4B 4A 49 48

28 47 46 45 44 43 42 41 40

27 3F 3E 3D 3C 3B 3A 39 38

26 37 36 35 34 33 32 31 30

25 2F 2E 2D 2C 2B 2A 29 28

24 27 26 25 24 23 22 21 20

23 1F 1E 1D 1C 1B 1A 19 18

22 17 16 15 14 13 12 11 10

21 0F 0E 0D 0C 0B 0A 09 08

Halesha H R 20 07 06 05 04 03 02 01 00
MICROCONTROLLER 18EC46
Address
8051 Internal RAM Memory: in Hex
7 6 5 4 3 2 1 0

Bit/Byte addressable RAM: 2F


2E
• Next 16 bytes from 20h to 2Fh are bit
2D
addressable. 2C

• Total number of bits are 128. 2B


2A 57 56 55 54 53 52 51 50

29 4F 4E 4D 4C 4B 4A 49 48

28 47 46 45 44 43 42 41 40

27 3F 3E 3D 3C 3B 3A 39 38

26 37 36 35 34 33 32 31 30

25 2F 2E 2D 2C 2B 2A 29 28

24 27 26 25 24 23 22 21 20

23 1F 1E 1D 1C 1B 1A 19 18

22 17 16 15 14 13 12 11 10

21 0F 0E 0D 0C 0B 0A 09 08

Halesha H R 20 07 06 05 04 03 02 01 00
MICROCONTROLLER 18EC46
Address
8051 Internal RAM Memory: in Hex
7 6 5 4 3 2 1 0

Bit/Byte addressable RAM: 2F


2E
• Next 16 bytes from 20h to 2Fh are bit
2D
addressable. 2C

• Total number of bits are 128. 2B 5F 5E 5D 5C 5B 5A 59 58

2A 57 56 55 54 53 52 51 50

29 4F 4E 4D 4C 4B 4A 49 48

28 47 46 45 44 43 42 41 40

27 3F 3E 3D 3C 3B 3A 39 38

26 37 36 35 34 33 32 31 30

25 2F 2E 2D 2C 2B 2A 29 28

24 27 26 25 24 23 22 21 20

23 1F 1E 1D 1C 1B 1A 19 18

22 17 16 15 14 13 12 11 10

21 0F 0E 0D 0C 0B 0A 09 08

Halesha H R 20 07 06 05 04 03 02 01 00
MICROCONTROLLER 18EC46
Address
8051 Internal RAM Memory: in Hex
7 6 5 4 3 2 1 0

Bit/Byte addressable RAM: 2F


2E
• Next 16 bytes from 20h to 2Fh are bit
2D
addressable. 2C 67 66 65 64 63 62 61 60

• Total number of bits are 128. 2B 5F 5E 5D 5C 5B 5A 59 58

2A 57 56 55 54 53 52 51 50

29 4F 4E 4D 4C 4B 4A 49 48

28 47 46 45 44 43 42 41 40

27 3F 3E 3D 3C 3B 3A 39 38

26 37 36 35 34 33 32 31 30

25 2F 2E 2D 2C 2B 2A 29 28

24 27 26 25 24 23 22 21 20

23 1F 1E 1D 1C 1B 1A 19 18

22 17 16 15 14 13 12 11 10

21 0F 0E 0D 0C 0B 0A 09 08

Halesha H R 20 07 06 05 04 03 02 01 00
MICROCONTROLLER 18EC46
Address
8051 Internal RAM Memory: in Hex
7 6 5 4 3 2 1 0

Bit/Byte addressable RAM: 2F


2E
• Next 16 bytes from 20h to 2Fh are bit
2D 6F 6E 6D 6C 6B 6A 69 68
addressable. 2C 67 66 65 64 63 62 61 60

• Total number of bits are 128. 2B 5F 5E 5D 5C 5B 5A 59 58

2A 57 56 55 54 53 52 51 50

29 4F 4E 4D 4C 4B 4A 49 48

28 47 46 45 44 43 42 41 40

27 3F 3E 3D 3C 3B 3A 39 38

26 37 36 35 34 33 32 31 30

25 2F 2E 2D 2C 2B 2A 29 28

24 27 26 25 24 23 22 21 20

23 1F 1E 1D 1C 1B 1A 19 18

22 17 16 15 14 13 12 11 10

21 0F 0E 0D 0C 0B 0A 09 08

Halesha H R 20 07 06 05 04 03 02 01 00
MICROCONTROLLER 18EC46
Address
8051 Internal RAM Memory: in Hex
7 6 5 4 3 2 1 0

Bit/Byte addressable RAM: 2F


2E 77 76 75 74 73 72 71 70
• Next 16 bytes from 20h to 2Fh are bit
2D 6F 6E 6D 6C 6B 6A 69 68
addressable. 2C 67 66 65 64 63 62 61 60

• Total number of bits are 128. 2B 5F 5E 5D 5C 5B 5A 59 58

2A 57 56 55 54 53 52 51 50

29 4F 4E 4D 4C 4B 4A 49 48

28 47 46 45 44 43 42 41 40

27 3F 3E 3D 3C 3B 3A 39 38

26 37 36 35 34 33 32 31 30

25 2F 2E 2D 2C 2B 2A 29 28

24 27 26 25 24 23 22 21 20

23 1F 1E 1D 1C 1B 1A 19 18

22 17 16 15 14 13 12 11 10

21 0F 0E 0D 0C 0B 0A 09 08

Halesha H R 20 07 06 05 04 03 02 01 00
MICROCONTROLLER 18EC46
Address
8051 Internal RAM Memory: in Hex
7 6 5 4 3 2 1 0

Bit/Byte addressable RAM: 2F 7F 7E 7D 7C 7B 7A 79 78

2E 77 76 75 74 73 72 71 70
• Next 16 bytes from 20h to 2Fh are bit
2D 6F 6E 6D 6C 6B 6A 69 68
addressable. 2C 67 66 65 64 63 62 61 60

• Total number of bits are 128. 2B 5F 5E 5D 5C 5B 5A 59 58

2A 57 56 55 54 53 52 51 50

29 4F 4E 4D 4C 4B 4A 49 48

28 47 46 45 44 43 42 41 40

27 3F 3E 3D 3C 3B 3A 39 38

26 37 36 35 34 33 32 31 30

25 2F 2E 2D 2C 2B 2A 29 28

24 27 26 25 24 23 22 21 20

23 1F 1E 1D 1C 1B 1A 19 18

22 17 16 15 14 13 12 11 10

21 0F 0E 0D 0C 0B 0A 09 08

Halesha H R 20 07 06 05 04 03 02 01 00
MICROCONTROLLER 18EC46
Address
8051 Internal RAM Memory: in Hex
7 6 5 4 3 2 1 0

Bit/Byte addressable RAM: 2F 7F 7E 7D 7C 7B 7A 79 78

2E 77 76 75 74 73 72 71 70
• Next 16 bytes from 20h to 2Fh are bit
2D 6F 6E 6D 6C 6B 6A 69 68
addressable. 2C 67 66 65 64 63 62 61 60

• Total number of bits are 128. 2B 5F 5E 5D 5C 5B 5A 59 58

2A 57 56 55 54 53 52 51 50
• Address Range is: 00h to 7Fh
29 4F 4E 4D 4C 4B 4A 49 48
• Bit may be specified by its address. 28 47 46 45 44 43 42 41 40

• So addresses 00h to 7Fh are may be bit 27 3F 3E 3D 3C 3B 3A 39 38

26 37 36 35 34 33 32 31 30
address or byte address.
25 2F 2E 2D 2C 2B 2A 29 28

24 27 26 25 24 23 22 21 20

23 1F 1E 1D 1C 1B 1A 19 18

22 17 16 15 14 13 12 11 10

21 0F 0E 0D 0C 0B 0A 09 08

Halesha H R 20 07 06 05 04 03 02 01 00
MICROCONTROLLER 18EC46
Address
8051 Internal RAM Memory: in Hex
7 6 5 4 3 2 1 0

Bit/Byte addressable RAM: 2F 7F 7E 7D 7C 7B 7A 79 78

2E 77 76 75 74 73 72 71 70
For example: Address 27h is a bit address of bit
2D 6F 6E 6D 6C 6B 6A 69 68
7 of 24h or it can be a byte address, it depends 2C 67 66 65 64 63 62 61 60

on the instruction. 2B 5F 5E 5D 5C 5B 5A 59 58

2A 57 56 55 54 53 52 51 50

29 4F 4E 4D 4C 4B 4A 49 48

28 47 46 45 44 43 42 41 40

27 3F 3E 3D 3C 3B 3A 39 38

26 37 36 35 34 33 32 31 30

25 2F 2E 2D 2C 2B 2A 29 28

24 27 26 25 24 23 22 21 20

23 1F 1E 1D 1C 1B 1A 19 18

22 17 16 15 14 13 12 11 10

21 0F 0E 0D 0C 0B 0A 09 08

Halesha H R 20 07 06 05 04 03 02 01 00
MICROCONTROLLER 18EC46
Address
8051 Internal RAM Memory: in Hex
7 6 5 4 3 2 1 0

Bit/Byte addressable RAM: 2F 7F 7E 7D 7C 7B 7A 79 78

2E 77 76 75 74 73 72 71 70
For example: Address 27h is a bit address of bit
2D 6F 6E 6D 6C 6B 6A 69 68
7 of 24h or it can be a byte address, it depends 2C 67 66 65 64 63 62 61 60

on the instruction. 2B 5F 5E 5D 5C 5B 5A 59 58

2A 57 56 55 54 53 52 51 50
MOV A, 27h; Byte address
29 4F 4E 4D 4C 4B 4A 49 48
MOV C, Bit address 28 47 46 45 44 43 42 41 40

27h; 27 3F 3E 3D 3C 3B 3A 39 38

26 37 36 35 34 33 32 31 30

25 2F 2E 2D 2C 2B 2A 29 28

24 27 26 25 24 23 22 21 20

23 1F 1E 1D 1C 1B 1A 19 18

22 17 16 15 14 13 12 11 10

21 0F 0E 0D 0C 0B 0A 09 08

Halesha H R 20 07 06 05 04 03 02 01 00
MICROCONTROLLER 18EC46
Address
8051 Internal RAM Memory: in Hex
7 6 5 4 3 2 1 0

Bit/Byte addressable RAM: 2F 7F 7E 7D 7C 7B 7A 79 78

2E 77 76 75 74 73 72 71 70
For example: Address 27h is a bit address of bit
2D 6F 6E 6D 6C 6B 6A 69 68
7 of 24h or it can be a byte address, it depends 2C 67 66 65 64 63 62 61 60

on the instruction. 2B 5F 5E 5D 5C 5B 5A 59 58

2A 57 56 55 54 53 52 51 50
MOV A, 27h; Byte address
29 4F 4E 4D 4C 4B 4A 49 48
MOV C, 27h; Bit address 28 47 46 45 44 43 42 41 40

• Addressable bits are useful when the 27 3F 3E 3D 3C 3B 3A 39 38

26 37 36 35 34 33 32 31 30
program needs to remember a binary event.
25 2F 2E 2D 2C 2B 2A 29 28

24 27 26 25 24 23 22 21 20

23 1F 1E 1D 1C 1B 1A 19 18

22 17 16 15 14 13 12 11 10

21 0F 0E 0D 0C 0B 0A 09 08

Halesha H R 20 07 06 05 04 03 02 01 00
MICROCONTROLLER 18EC46
8051 Internal RAM Memory: Address
in Hex
General purpose RAM 7F
• Above the bit area from 30h to 7Fh, is
general purpose RAM, and they are
byte addressable.
Directly and Indirectly
addressable general
purpose RAM

Can be used as Stack


area

30
Halesha H R
MICROCONTROLLER 18EC46
8051 Internal Extended Memory:
• Internal RAM is 128 byte.
• Minimum address bits required is 7-bits.
• To represent in hexadecimal, consider 8-bits
• Maximum address range is: 00h to FFh.
• 00h to 7Fh are used.
• 80h to FFh are not used.
• Can’t be used as general purpose memory.
• Used for SFR’s, and all addresses are not used.

Halesha H R
MICROCONTROLLER 8051 Internal Extended Memory: 18EC46
8F Un-us 9F AF CF FF
DF EF
ed
8E to BF
8D TH1 Un-us
to ed Un-us Un-us
8C TH0 to ed to ed
8B TL1

8A TL0 9A

89 TMOD 99 SBUF A9 B9 Un-us Un-us Un-us


to to to
88 TCON 98 SCON A8 IE B8 IP to Un-us ed ed ed
ed
87 PCON 97 A7 B7

86 Un-us
ed
84 to Un-us Un-us Un-us
to ed to ed to ed
83 DPH

82 DPL

81 SP 91 A1 B1 D1 E1 F1
80 Port 0 90 Port 1 A0 Port 2 B0 Port 3 C0 D0 PSW E0 A F0 B

Halesha H R
MICROCONTROLLER 18EC46
Internal ROM:
• Different family members have different ROM sizes.
• 8751, AT8951 have 4K bytes of ROM on chip;
• AT89C52 has 8K bytes;
• DS5000-32 has 32K bytes and so on.
• But can’t access more than 64K bytes of opcode, since the program
counter is 16-bits (0000h to FFFFh).
• First location of is 0000h, last location can differ, depending on the size
of the ROM on chip.
• If ROM size is 4k, the address range is 0000h to 0FFFh.

Halesha H R
MICROCONTROLLER 18EC46

Thank you

Halesha H R

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy