You are on page 1of 210

Semester V L T P C

Course Code/
191EC511/MICROPROCESSORS AND MICROCONTROLLERS 3 0 0 3
Title
 To understand the Architecture of 8086 Microprocessor and 8051Microcontroller
 To interface 8086
Objectives  Microprocessor and 8051 Microcontroller with supporting chips.
 To design a microcontroller based system.
Unit-I THE 8086 MICROPROCESSOR 9
Overview of Microprocessors, 8086 – Architecture ,Signals, Addressing modes , Instruction set and assembler directives ,
Assembly language programming , Stacks , Procedures ,Macros , Interrupts and interrupt service routines , Introduction to
advanced microprocessors.
Unit-II PERIPHERAL INTERFACING AND PROGRAMMING 9
Parallel communication interface, Serial communication interface, D/A and A/D Interface, Timer, Keyboard /display
controller , DMA controller, Traffic Light control Interfacing Techniques.
Unit-III 8051 MICROCONTROLLER 9
Functional block diagram and pin diagram of 8051-Special Function register-Program and Data Memory organization-
addressing modes. Instruction Set: data transfer, arithmetic and logical, program branching instructions and Boolean
variable manipulation.
Unit-IV ON-CHIP PERIPHERALS AND PROGRAMMING TECHNIQUES 9
Input output pins, ports and circuits, timer/counter-Operating Modes-Programming 8051 Timers - Counter Programming-
Serial Communication: Basics of Serial Communication Modes-Serial Port Programming. Interrupt: 8051 Interrupt-
External and Internal Interrupts- Programming timer Interrupts, external hardware interrupts and serial communication
interrupts -Interrupt Priority and Programming.
Unit-V PERIPHERAL INTERFACING AND PROGRAMMING 9
D/A and A/D Interface, LED interfacing, LCD interfacing, Keyboard /display Interface, Sensor Interfacing, and Stepper
Motor Interfacing Techniques, Comparison of 8051, PIC, ARM.
1. Analyze and implement programs on 8086 microprocessor.
2. Interface the peripherals and I/O devices with 8086 microprocessor.
Outcomes 3. Interpret 8051 microcontrollers’ architectures and its functionalities.
4. Design and development of 8051 microcontroller based systems for real time applications
5. Interface the peripherals and I/O devices using 8051 microcontroller.
TextBooks
1. Muhammad Ali Mazidi, J.G. Mazidi, R.D. McKinlay,”The 8051 Microcontroller and Embedded Systems”, Second
Edition, Prentice Hall of India Pvt. Ltd., 2007.
2. A.K.Ray,K.M.Bhurchandi, "Advanced Microprocessors and Peripherals" 3rd edition, Tata McGrawHill, 2012.
References
1. Krishna Kant, “Microprocessors and Microcontrollers- Architecture, programming and system design 8085, 8086,
8051,8096”, Prentice Hall of India, New Delhi, 2007.
2. Kenneth J Ayala, “The 8051 Microcontroller – Architecture, Programming and Applications”,Penram
International Publications, Mumbai India, 1996.
3. DoughlasV.Hall,”Microprocessors and Interfacing, Programming and Hardware”, TMH, 2012
UNIT – I

THE 8086 MICROPROCESSOR

Overview of Microprocessor:
STACK
Intel 80186
• 80186 contain a 16-bit data bus.
• The internal register structure of the 80186 is virtually identical to the 8086.
• The only difference is that the 80186 contain additional reserved interrupt vectors and some
very powerful built in I/O
features
• The 80186 and 80188 are often called embedded controllers because of their application as a
controller, not as a microprocessor-based computer.
• The 80186 contains 16 bit data bus.
• The internal register structure of 80186 is virtually identical to the 8086.
• Enhanced 8086-2 CPU.
• Clock Generator.
• 2 Independent DMA Channels.
• Programmable Interrupt Controller.
• 3 Programmable 16-bit Timers.
• Programmable Memory and Peripheral Chip-Select Logic.
• Available in 10 MHz and 8 MHz Versions.
• Direct Addressing Capability to 1 Mbyte of Memory and 64 Kbyte I/O
Intel 80286
The 80286 is the first member of the family of advanced microprocessors with memory management
and protection abilities.
Features
• The 80286 microprocessor is an advanced version of the 8086 microprocessor that is designed
for multi user and multitasking environments.
• The 80286 addresses 16 M Byte of physical memory and 1G Bytes of virtual memory by using its
memory-management system.
• The 80286 is basically an 8086 that is optimized to execute instructions in fewer clocking periods
than the 8086.
• Various versions of 80286 are available that runs on 12.5 MHz , 10 MHz and 8 MHz clock
frequencies.
• Like the 80186, the 80286 doesn’t incorporate internal peripherals; instead it contains a
memory management unit (MMU).
• The 80286 operates in both the real and protected modes
• In the real mode, the 80286 addresses a 1MByte memory address space and is virtually identical
to 8086.
• In the protected mode, the 80286 addresses a 16MByte memory space.
Intel 80386
Features
• 32-bit general and offset registers.
• 16-byte prefetch queue.
• Memory Management Unit with a Segmentation Unit and a Paging Unit.
• 32-bit Address and Data Bus.
• 4-Gbyte Physical address space.
• 64-Tbyte virtual address space.
• i387 numerical coprocessor with IEEE standard-754-1985 for floating point arithmetic.
• 64K 8-, 16-, or 32-bit ports.
• Implementation of real, protected and virtual 8086 modes.
• The protection mode opeartion provides paging,virtual addressing,multilevel protection and
multitasking capabilities.
UNIT 2 PERIPHERAL INTERFACING AND
PROGRAMMING
-tr 1~~(., ~r Mr u.~ Pff J
f ~-rr ..\ -o/ ~ , f\}p'rtt.)
f~ ~l +o Qi,IAih ~ -
fA-1 Y, P~t- ~ - wn~lw~t- +o
PPr Gt t E.~ ct ~«>'h.,
&i'., 'I'!> f_~ 2-

f .B '.2- f BI f,Bo
12-.,_ p~
'I PJ~
Gr p~
2-

~B~ YB(i fg{" ~ ~ fb,. PB, ~


-
~)(_ ff\ ?ti.t TA< r~ 1'~ fJ-'). ?,,, ~o ~

fl1 I!_,_ bii \ to t) l b b L t? \ 0


~~H
b (9 C, 0- 0 D I
"1 1,t

<.

t, 1) } 0 t>
'I{ '-f 2 Y31/4
0 \ 0 D
' D
~H
b 0 f) I 0 \i
tt'

rt
·o ·\ I oq~
() 0 \ V D r 0 0 ct~~
~l ~ 2- ~ R¼
Q
G 0 C1 0

..,

-
~l)V A-L1 ~~

C)t)T ~3 , ~L 'tl'J O'\) .Bx.,


l)~: DFFF
J....oc, p : thov .+L, oq ~ ~ : be: e- B><.
g)uT ~~AL
cirJ2- L
~O'\I +t...r ~~ H bJ=-c C.L
9UT

}I') ov
~t1
~/
A-L--

it g-.
Jf\/2.

tcr
tuo
L/rt..L !i) ~ \/ft y
~ fJV -'o--L.., l~ i-t
r)\l'f f o~ Pr-L
e) VT g-11 "4 L
~ev c1.-, o A-
C,+ t.. L- ~ E '-fr Y

v'PJcv +t-, Rl.t H


0ITT ~f .,t- l-
J'--f'J ov tr L.1 o Cf rt
OUT ~ I-, ~ L--

thov C 1,,1 tR_~ t-1


~'4-L 1,, D6\bf- j
ffJov + c.. ., 1-'( H
DU1 <tt>i+, tr- L-
OVT ~1t1 r .+r-
~ov C t..-/DA H
r ,4- ,-, f) s. 1.-AV ·
UNIT 3 8051 Microcontroller

Features of Microcontroller:
The 8051 Features are like below
 8051 has 8-bit Processing Unit to control applications.
 Using 8051 we can process bits, or in other words, the bit processing
capability is present in the 8051microcontroller.
 8051 has separate Data memory and separate program memory spaces.
The program memory is basically 4KBof on-chip EPROM (address space
0000H to 0FFFH), and 128 bytes of RAM (address space 00H to 7FH)
 There is total 64KB of program memory address space including the on-
chip 4KB space.
 The RAM Address space (128 bytes) is not considered in the 64KB space.
 There are four 8-bit ports, so 32bi-directional and individually addressable
IO lines.
 It also has two 16-bit timers or counters T0 and T1.
 It has full duplex UART (universal asynchronous Receiver Transmitter)

Functional Block diagram of 8051

8-bit Microcontroller
The 8051 Microcontroller is an 8-bit Microcontroller. The width of the data bus is
8-bits. The data bus is utilized to carry data from specific operations.
Consequently, the CPU can process 8 bits of data at one time.
Memory
A Microcontroller needs program memory to store program/instructions to
perform defined tasks. This memory is termed as ROM. Furthermore the
Microcontroller also requires data memory to store the operands/data on a
temporary basis. This memory is known as RAM. The 8051 Microcontroller is
built with 4 Kb on-chip Read Only Memory (ROM) and 128 bytes Random
Access Memory (RAM).

Address Bus
A bus of the Microcontroller can be defined as a group of wire which can act as a
medium for the transfer of data. There are two buses present in the 8051
Microcontroller. While we are already aware of the Data Bus, let us know about
the Address Bus of the 8051 Microcontroller. The address bus, which is used to
address memory locations, is 16-bit wide. Furthermore, the address bus can also
be used to transfer data from the CPU (Central Processing Unit) to the
memory. Hence, for obvious reasons the address bus is unidirectional.

Interrupts
The most powerful attribute of the 8051 Microcontroller is the concept of
Interrupts. The interrupt is a mechanism to –

 Temporarily suspend the ongoing program,


 Pass the control to a subroutine,
 Execute the subroutine,
 Resume the ongoing/main program.
Interrupts can be of various types, such as, Software and Hardware interrupts,
Non-maskable and maskable interrupts, etc.

Now the 8051 Microcontroller incorporates five interrupts. These are :

1. INT0 – External Hardware Interrupt.


2. TF0 – Timer 0 Overflow Interrupt.
3. INT1 – External Hardware Interrupt.
4. TF1 – Timer 1 Overflow Interrupt.
5. R1/T1 – Serial communication Interrupt.
Input/Output Ports
The 8051 Microcontroller needs to be connected to the peripheral devices in
order to control their operations. The I/O Ports are responsible for the connection
of the Microcontroller to its peripheral devices. There are total Four 8-bit
Input/Output Ports present in this Microcontroller.

Additionally, these are some important features of 8051 microcontroller given as


follows :

1. Two 16-bit Timers and Counters.


2. A Data Pointer and a Program Counter of 16-bit each.
3. 128 User defined Flags.
4. Four Register banks.
5. 31 General Purpose Registers which are of 8-bit each.

Architecture of 8051
Arithmetic and Logical Unit (ALU)

ALU performs arithmetic like addition, subtraction, multiplication and Logical


Operations like NAND, NOR etc.
Internal RAM in Detail

Internal RAM of 8051 it is divided into 3 main sections:

1. Register Banks

There are 32 8-bit registers arranged in 4 groups. These are used as general purpose
registers.
2. Bit Addressable RAM

8051 has 16 bytes of RAM, which is bit addressable. It is grouped as 16, 8 byte
arrays and any of the 128 bits can also be set/cleared individually.
3. Scratch PAD RAM

The third group of registers occupy addresses 2Fh-7Fh, i.e. 80 locations, and does
not have any special functions or features. Scratch pad RAM is used by the ALU,
while fetching, decoding and executing the instructions during operation of the
microcontroller.
System Timing, Interrupts, Timers, Data Buffers and Memory Control

 System Timing, refers to the entire timing unit of the microcontroller. The primary
source of timing for 8051 is external crystal. The system timing unit is mainly
responsible for providing timing to critical events like instruction fetch, decode and
execute operations.
 Interrupts: 8051 provides a method to stop current execution and switch over to a
priority task with the use of Interrupts. They are associated with external pins
P3.2(INT0) and P3.3(INT1). As well as internal units like timers and serial
communication. Thus an interrupt to 8051 can be external generated by peripheral
device or internal from one of its inbuilt units sometimes referred as software
interrupt.
 Timers/Counters: Again one of the most widely used features, timers are used to
count time internally or can be made to count external event as counters.
 Memory Control: It is an internal unit of the microcontroller, responsible for
accessing data from RAM and ROM.
After a reset, the program counter is loaded with 0000H but the content of on-chip RAM is not
affected.
OSCILLATOR CIRCUIT OF 8051 CONTROLLER

 The 8051 uses the crystal for precisely that to synchronize it’s operation. Effectively, the 8051
operates using what are called "machine cycles."
 A single machine cycle is the minimum amount of time in which a single 8051 instruction can be
executed although many instructions take multiple cycles.
 8051 has an on-chip oscillator. It needs an external crystal that decides the operating frequency
of the 8051.

This can be achieved in two ways.


The crystal is connected to pins 18 and 19 with stabilizing capacitors. 12 MHz
(11.059MHz) crystal is often used and the capacitance ranges from 20pF to 40pF.
The oscillator can also be a TTL clock source connected with a NOT gate as shown.
Addressing Modes
In 8051 There are six types of addressing modes.
 Immediate Addressing Mode
 Register Addressing Mode
 Direct Addressing Mode
 Register Indirect Addressing Mode
 Indexed Addressing Mode
 Implied Addressing Mode
Immediate addressing mode
In this Immediate Addressing Mode, the data is provided in the instruction itself.
The data is provided immediately after the opcode. These are some examples of
Immediate Addressing Mode.

MOVA, #0AFH;

MOVR3, #45H;

MOVDPTR, #FE00H;

In these instructions, the # symbol is used for immediate data. In the last
instruction, there is DPTR. The DPTR stands for Data Pointer. Using this, it
points the external data memory location. In the first instruction, the immediate
data is AFH, but one 0 is added at the beginning. So when the data is starting
with A to F, the data should be preceded by 0.

Register addressing mode


In the register addressing mode the source or destination data should be present
in a register (R0 to R7). These are some examples of RegisterAddressing Mode.

MOVA, R5;

MOVR2, #45H;

MOVR0, A;

In 8051, there is no instruction like MOVR5, R7. But we can get the same result
by using this instruction MOV R5, 07H, or by using MOV 05H, R7. But this two
instruction will work when the selected register bank is RB0. To use another
register bank and to get the same effect, we have to add the starting address of
that register bank with the register number. For an example, if the RB2 is
selected, and we want to access R5, then the address will be (10H + 05H =
15H), so the instruction will look like this MOV 15H, R7. Here 10H is the starting
address of Register Bank 2.

Direct Addressing Mode


In the Direct Addressing Mode, the source or destination address is specified by
using 8-bit data in the instruction. Only the internal data memory can be used in
this mode. Here some of the examples of direct Addressing Mode.

MOV80H, R6;
MOVR2, 45H;

MOVR0, 05H;

The first instruction will send the content of registerR6 to port P0 (Address of Port
0 is 80H). The second one is forgetting content from 45H to R2. The third one is
used to get data from Register R5 (When register bank RB0 is selected) to
register R5.

Register indirect addressing Mode


In this mode, the source or destination address is given in the register. By using
register indirect addressing mode, the internal or external addresses can be
accessed. The R0 and R1 are used for 8-bit addresses, and DPTR is used for
16-bit addresses, no other registers can be used for addressing purposes. Let us
see some examples of this mode.

MOV0E5H, @R0;

MOV@R1, 80H

In the instructions, the @ symbol is used for register indirect addressing. In the
first instruction, it is showing that theR0 register is used. If the content of R0 is
40H, then that instruction will take the data which is located at location 40H of the
internal RAM. In the second one, if the content of R1 is 30H, then it indicates that
the content of port P0 will be stored at location 30H in the internal RAM.

MOVXA, @R1;

MOV@DPTR, A;

In these two instructions, the X in MOVX indicates the external data memory.
The external data memory can only be accessed in register indirect mode. In the
first instruction if the R0 is holding 40H, then A will get the content of external
RAM location40H. And in the second one, the content of A is overwritten in the
location pointed by DPTR.
Indexed addressing mode
In the indexed addressing mode, the source memory can only be accessed from
program memory only. The destination operand is always the register A. These
are some examples of Indexed addressing mode.

MOVCA, @A+PC;
MOVCA, @A+DPTR;

The C in MOVC instruction refers to code byte. For the first instruction, let us
consider A holds 30H. And the PC value is1125H. The contents of program
memory location 1155H (30H + 1125H) are moved to register A.

Implied Addressing Mode


In the implied addressing mode, there will be a single operand. These types of
instruction can work on specific registers only. These types of instructions are
also known as register specific instruction. Here are some examples of Implied
Addressing Mode.

RLA;

SWAPA;

These are 1- byte instruction. The first one is used to rotate the A register content
to the Left. The second one is used to swap the nibbles in A.
Scanned by CamScanner
Scanned by CamScanner
Scanned by CamScanner
Scanned by CamScanner
Scanned by CamScanner
Scanned by CamScanner
Scanned by CamScanner
Scanned by CamScanner
Scanned by CamScanner
Scanned by CamScanner
Scanned by CamScanner
Scanned by CamScanner
Write an ALP FOR FLASHING OF LEDS WITH A DELAY OF 1 MILLI SEC
L1: MOV PO,#FF
ACALL DELAY
L1: MOV PO,#00
ACALL DELAY
SJMP L1

DELAY: MOV R6,#250D


MOV R7,#250D
LABEL1: DJNZ R6,LABEL1
LABEL2: DJNZ R7,LABEL2
RET
Scanned by CamScanner
Scanned by CamScanner
Scanned by CamScanner
8051 PIC ARM

Bus width 8-bit for standard 32-bit mostly also


core 8/16/32-bit available in 64-bit
UART, USART, LIN,
I2C, SPI, CAN, USB,
Ethernet, I2S, DSP,
Communication PIC, UART, USART, SAI (serial audio
Protocols UART, LIN, CAN, Ethernet, interface), IrDA
USART,SPI,I2C SPI, I2S
Speed 12 Clock/instruction 4 Clock/instruction 1 clock/ instruction
cycle cycle cycle
Memory ROM_ SRAM_ Flash-SDRAM,
FLASH SRAM_ FLASH EEPROM
Some feature of
ISA RISC
CLSC RISC
Memory
Architecture Von Neumann Modified Harvard
architecture Harvard architecture architecture
Power
Consumption
medium Low Low
Families PIC16,PIC17, PIC18, ARMv4,5,6,7 and
8051 variants PIC24, PIC32 series
Community
Vast Very Good Vast
Apple, Nvidia,
NXP, Atmel, Silicon Qualcomm, Samsung
Manufacturer Labs, Dallas, Cyprus, Electronics, and TI
Infineon, etc. Microchip Average etc.
Cost (as
compared to
features provide) too Low medium Low
High-speed operation
Other Feature Known for its Vast
Standard Cheap
Popular PIC18fXX8, LPC2148, ARM
Microcontrollers AT89C51, P89v51, PIC16f88X, Cortex-M0 to ARM
etc. PIC32MXX Cortex-M7, etc.

You might also like