Es Unit1-2
Es Unit1-2
MICROCONTROLLER
MOTIVATION
Timer
Interrupt
Serial Port
Parallel Port
Microprocessor
No RAM, ROM, I/O, ports on CPU chip itself
They are connected externally
Example : Intel’s 8086, Motorola’s 680x0
Microcontroller
A control device which incorporates a
microprocessor.
On-chip RAM, ROM, I/O ports...
Example: Motorola’s 6811, Intel’s 8051, Zilog’s
Z8 and PIC 16X
Definition of microcontroller
An Integrated circuit that contains a
Microprocessor along with memory and associated
circuits and that controls some or all of the
functions of an electronic device (such as a home
appliance) or system.
Comparison
Features of 8051
40 pin DIP.
8-bit data bus & 8-bit ALU
16-bit address bus
4 KB on chip program memory (ROM or EPROM)).
128 bytes on chip data memory(RAM).
32 general purpose registers each of 8 bits
Two -16 bit timers T0 and T1
Five Interrupts (3 internal and 2 external).
Four Parallel ports each of 8-bits (PORT0, PORT1,PORT2,PORT3) with a
total of 32 I/O lines.
One 16-bit program counter and One 16-bit DPTR ( data pointer)
One 8-bit stack pointer
One full duplex serial communication port
Types of Microcontrollers
Bit
8-bit microcontroller − This type of microcontroller is
used to execute arithmetic and logical operations like
addition, subtraction, multiplication division, etc. For
example, Intel 8031 and 8051 are 8 bits microcontroller.
16-bit microcontroller − This type of microcontroller is
used to perform arithmetic and logical operations where
higher accuracy and performance is required. For example,
Intel 8096 is a 16-bit microcontroller.
32-bit microcontroller − This type of microcontroller is
generally used in automatically controlled appliances like
automatic operational machines, medical appliances, etc.
Memory
External memory microcontroller − This type of
microcontroller is designed in such a way that they do not
have a program memory on the chip. Hence, it is named as
external memory microcontroller. For example: Intel 8031
microcontroller.
Embedded memory microcontroller − This type of
microcontroller is designed in such a way that the
microcontroller has all programs and data memory,
counters and timers, interrupts, I/O ports are embedded on
the chip. For example: Intel 8051 microcontroller.
Instruction Set
CISC − CISC stands for complex instruction set computer.
It allows the user to insert a single instruction as an
alternative to many simple instructions.
RISC − RISC stands for Reduced Instruction Set
Computers. It reduces the operational time by shortening
the clock cycle per instruction.
ARCHITECTURE & BLOCK DIAGRAM
OF 8051 MICROCONTROLLER:
It consists of an 8-bit ALU, one 8-bit PSW(Program Status
Register), A and B registers , one 16-bit Program counter ,
one 16-bit Data pointer register(DPTR),128 bytes of RAM
and 4kB of ROM and four parallel I/O ports each of 8-bit
width.
Architecture
Components included in 8051 Architecture
Ground
1-8=P1, 10-17=P3, 39-32=P0, 28-21=P2
Port 0,1,2,3 Zero---Output, One---Input
• One of the most useful features of the 8051 is that it contains four I/O
ports (P0 - P3)
Harvard Architecture
8051 Microcontroller Memory Organization
74ls373
Latch
Data Memory (RAM) of 8051
Microcontroller
The Data Memory or RAM of the 8051
Microcontroller stores temporary data and intermediate
results that are generated and used during the normal
operation of the microcontroller.
Original Intel’s 8051 Microcontroller had 128B of
internal RAM.
In the 8051 family, 8051 has total 128 bytes of internal
data RAM and we can interface external data memory
up to 64K. Hence, total size of data memory in 8051
can be up to external 64K + internal 128 bytes.
The basic 8051 architecture supports 128 bytes of
internal data memory and 128 bytes of SFR(Special
function Register) Memory.
SFR Memory is not available for the user for
general data memory applications.
The Address range of internal user data memory is
00H to7FH.
SFR’s are residing at memory area from 80H to
FFH.
DATA MEMORY
RAM is divided into 3 parts:- 1) Register banks 2) Bit
addressable area 3) Scratch pad area.
Register banks
There are 4 register banks in 8051 bank 0,1, 2 and 3.
Each bank has 8 registers of 1 byte R0,R1…R7
respectively.
Hence, register banks consist of the lowest 32 bytes of
on chip RAM
At a time only one register bank can be selected for
operations and bank registers are accessed using
mnemonics R0..R1.. etc.
By default register bank 0 is selected when we reset
the system.
Bit addressable area
The bit addressable area is 16 bytes next to register banks.
We can access each bit separately of bit addressable area, Each
bit have unique address of bit addressable area.
Bit addressable area is mainly used to store bit variables from
application program, like status of an output device like LED or
Motor (ON/OFF) etc. We need only a bit to store this status
The area of bit addressable space of 8051 is usually used to store
bit variables. address range 20H to 2FH (total 128 bits)
Each bits can be accessed from 00H to 7FH within this 128 bits
from 20H to 2FH.
Sometimes programming using bit addressable area saves
wastage of memory.
Scratch pad area
The upper 80 bytes are nothing but scratch pad area
which is used for general purpose storing of data.
Scratch pad area is in the address range 30H to
7FH .
Scratch pad area can be used for stack memory also
if default stack area is insufficient.
External Data Memory interfacing to 8051
EA Latch(e.e. A0...A7
Ground 74LS373)
ALE
External data
memory
Higher order Address bus
P2 A8..A15
RD OE
P3
WR WR
EA
Ground
Instruction Set of 8051
As you studied in the basic 8085/8086 microprocessor class,
an instruction consists of 2 parts:
1. Opcode and
2. Operands
The opcode tells the processor what to do on executing an
instruction.
The operands is the parameters required by opcode to
complete the action.
The term instruction set refers to set of instructions supported
by the processor/controller architecture.
Contd..
A computer instruction is made up of an operation code (op-code)
followed by either zero, one or two bytes of operands
The op-code identifies the type of operation to be performed while
the operands identify the source and destination of the data
The operand can be:
The data value itself
A CPU register
A memory location
An I/O port
Logical instructions