SlideShare a Scribd company logo
1 of 81
Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA
INTERRUPTS OF 8086,
INTRODUCTION TO 8051
UNIT 5
Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA
Introduction to 8051
Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA
● To make a complete microcomputer system, only microprocessor is not
sufficient.
● It is necessary to add other peripherals such as ROM, read/write memory
(RAM), decoders, drivers, number of input/output devices to make a complete
microcomputer system.
● In addition special purpose devices such as interrupt controller,
programmable timers, programmable i/o devices, DMA controllers may be
added to improve the capability, performance and flexibility of a
microcomputer system.
● The key feature of microprocessor based system is that is possible to design
a system with great flexibility and possible to configure a system as large or
small system by adding suitable peripherals.
Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA
● On the other hand the microcontroller incorporates all the features that are
found in microprocessor.
● However it has also added features to make a complete microcomputer
system on its own.
● The microcontroller has built-in ROM, RAM, parallel I/O, serial I/O, counters
and a clock circuit.
● The microcontroller has on-chip (built in) peripheral devices that make
possible to have single chip microcomputer system.
Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA
Difference between
Microcontroller
& Microprocessor
Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA
8051 Features
● The 8051 is an 8-bit microcontroller designed by Intel.
● It was optimized for 8-bit math and single bit Boolean operations.
● Its family MCS-51 includes 8031, 8051 and 8751 microcontrollers.
● The 8051 is an 8-bit microcontroller with 8 bit data bus and 16-bit address bus.
● The 16 bit address bus can address a 64K( 216) byte code memory space and
a separate 64K byte of data memory space.
● The 8051 has 4K on-chip read only code memory and 128 bytes of internal
Random Access Memory(RAM)
Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA
8051 Features
● Besides internal RAM, the 8051 has various Special Function Registers (SFR)
such as the Accumulator, the B register, and many other control registers.
● 34 8-bit general purpose registers in total.
● The ALU performs one 8-bit operation at a time.
● Two 16 bit /Counter timers
● 3 internal interrupts (one serial), 2 external interrupts.
● Four 8-bit I/O ports
● Some 8051 chips come with UART for serial communication and ADC for analog
to digital conversion.
Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA
Pin Diagram
Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA
● Pin 1 to Pin 8 (Port – 1) – Pin 1 to Pin 8 is assigned to Port 1 for simple I/O
operations. These ports are work as a bidirectional port. It means all the pins of port 1 work
as a input pin or output pins. If Logic 1 (one) is applied to the I/O port it will act as a input pin
and if logic 0 (zero) is applied to the I/O port it will act as a output pin.
● Pin 9 (RST) – It is a reset input Pin, which is used to reset the 8051 microcontrollers to its
initial values when logic 1 is applied to this pin. It is active high pin.
● Pin 10 to Pin 17 (Port-3) – Pin 10 to Pin 17 are assigned to Port 3. This port is also a
bidirectional I/O port like port 1. This port performs some special functions like interrupts,
control signals, timer input, serial communication etc. These are explained in detail as below.
Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA
● P 10 (RXD) – Pin 10 is used as a RXD (serial data receive pin) which is for serial input pin.
By using this input signal microcontroller receives data for serial communication.
● P 11 (TXD) – Pin 11 is used as a TXD (serial data transmit pin) which is serial output pin. By
using this output signal microcontroller transmits data for serial communication.
● P 12 and P 13 (INT0′, INT1′ ) – Pins12 and 13 are used for External Hardware Interrupt 0
and Interrupt 1 respectively. When this interrupt is activated (i.e. when it is low), 8051 gets
interrupted means it stopped whatever it is doing and jumps to the vector table where ISR’s
(Interrupt Service Routine) are stored and starts performing Interrupt Service Routine (ISR)
from that vector location.
Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA
● P 14 and P 15 (T0 and T1) – Pin 14 and 15 are used for Timer 0 and Timer 1
external input. They can be connected with 16-bit timer/counter.
● P 16 (WR’) – Pin 16 is used for external memory write i.e. writing data to the
external memory.
● P 17 (RD’) – Pin 17 is used for external memory read i.e. reading data from
external memory.
● Pin 18 and Pin 19 (XTAL2 And XTAL1) –Pins 18 and 19 i.e. XTAL 2 and XTAL 1
are the pins for interfacing external oscillator. Mostly, a Quartz Crystal Oscillator is
connected here to get the system clock.
Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA
● Pin 20 (GND) – Pin 20 is the Ground Pin. It is connected to the 0V (negative terminal) of the
Power Supply.
● Pin 21 to Pin28 (Port 2) – Pin 21 to pin 28 are Port 2 pins. Port 2 is also a bidirectional Input
/Output port i.e. all pins of port 2 work as a input pin or as a output pins. But, this is only
possible when we are not using any external memory. If we use external memory, then these
pins will work as high order address bus (A8 to A15).
● Pin 29 (PSEN) – The Pin 29 is the Program Strobe Enable Pin (PSEN). It is used to enable
external program memory and read a signal from the external program memory.
● Pin 30 (ALE) – Pin 30 is the Address Latch Enable Pin. This pin is used to enable or disable
the external memory interfacing.
Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA
● Pin 31 (EA) – Pin 31 is the External Access Enable (EA) Pin. This pin allows external
Program Memory. It is an input pin and connected from VCC or GND. If we want to access
the program from external program memory, it must be connected with GND. If we want to
use on-chip memory, it must be high (connected with VCC).
● Pin 32 to Pin 39 (Port 0) – Pin 32 to Pin 39 are Port 0 pins. When we don’t use any external
memory, these pins are used as a bidirectional pin like port 2 and port 3. But, when ALE or
Pin 30 is at 1, then this port is used as data bus. And when the ALE pin is at 0, then this port
is used as a lower order address bus (A0 to A7).
● Pin 40 (VCC) – This pin is used to provide (+5v ) power supply to the 8051 microcontroller
circuit.
Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA
8051 Microcontroller Basic Circuit
Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA
Architecture of 8051
Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA
Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA
Functional Units:
● Central Processing Unit (CPU)
● Memory – 128bytes RAM & 4kB ROM
● I/O ports
● Special Function Registers
● Serial Port
Central processing Unit:
● ALU
● Registers – A,B, PSW, temporary registers
● 16 bit program counter (PC)
● Data pointer (DPTR) & Stack pointer (SP)
Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA
Arithmetic Logic Unit (ALU):
● It can perform 8-bit arithmetic operations
● It can also manipulate one bit and 8bit logical operations.
Accumulator (Register A):
● It is an 8-bit register
● It is used to hold the source operand and also receives the result of the function.
Register B:
● It is an 8bit register used as general purpose register
Special Function Register (SFR):
● In 8051, access to the I/O ports, CPU registers, Timer/counter, Logic control
registers can be done through the SFRs (located from 80H to FFH).
Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA
Program Status Word Register (PSW):
CY AC F0 RS1 RS0 OV - P
B7 B6 B5 B4 B3 B2 B1 B0
Carry Flag Auxiliary
Carry
flag
Flag 0 Register Bank
Select Signals
Overflow Flag
Parity Flag
Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA
Data Pointer (DPTR):
● It is a 16bit register used to hold a 16 bit address.
● It is used as a base register in JUMP/Lookup table instructions and external
data transmission.
Program Counter (PC):
● It is a 16 bit register used to hold the address of memory location from which
the next instruction is to be fetched.
DPH DPL
16 bit DTPR
8 bit 8 bit
Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA
System Bus:
● The system bus consists of an 8-bit data bus, 16-bit address bus and control
signals.
● It is used to connect all the internal devices to the CPU.
I/O ports:
● 8051 has 32 bidirectional I/O pins which are organized as four parallel 8-bit
I/O ports.
Port 0 : I/O ports & multiplexed AD0 – AD7
Port 1 : Only for I/O
Port 2 : I/O ports & Higher – order Address A8- A15
Port 3 : I/O ports & multifunctional
Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA
Serial Port:
● The serial port of 8051 is full-duplex i.e. it can transmit and receive from/to an
external device.
● Used for serial communication
Memory:
● For operation Micro-controller required a program. This program guides the
microcontroller to perform the specific tasks. This program installed in
microcontroller required some on chip memory for the storage of the program.
● Microcontroller also required memory for storage of data and operands for the
short duration.
● In microcontroller 8051 there is code or program memory of 4 KB that is it has
4 KB ROM and it also comprise of data memory (RAM) of 128 bytes.
Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA
Interrupt:
● 8051 provides 5 interrupt sources
● External hardware interrupts : INT0, INT1
● External Timer Interrupts : TF0, TF1
● Serial Communication Interrupt : RI/ TI
Oscillator:
● A clock signal allows the operations inside the microcontroller and other parts
to be synchronous.
● A Clock Generator is an integral part of the Microcontroller’s Architecture and
the user has to provide an additional Timing Circuit in the form of a Crystal.
Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA
8051 Memory Organization
Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA
● The 8051 microcontroller's memory is divided into Program Memory and Data
Memory. Program Memory (ROM) is used for permanent saving program being
executed, while Data Memory (RAM) is used for temporarily storing and keeping
intermediate results and variables.
1.Program memory: (4kB ROM)
● Program memory accessed through EA pin. In program memory two categories
takes place:
a)If EA is high, internal program memory is accessed up to 0FFFH memory
location and external program memory accessed from 1000H to FFFFH memory
locations.
b)If EA is low, only external program memory accessed from 0000H to FFFFH
memory locations.
Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA
Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA
2.Data memory:
● Data memory is used to store the memory in the registers each of 64k bytes size,
to access the data memory instruction MOVX is used. Data memory is of two
types Internal and external.
i) Internal data memory:
● The internal data memory consists of 256 bytes, these are divided into two parts:
a) 00H-7FH for internal data RAM (lower 128 bytes)
b) 80H-FFH for special function registers (upper 128 bytes)
ii) External data memory:
● The 8051 gives the facility to interface external RAM and ROM. External RAM is
accessed by DPTR and up to 64KB of RAM can be interfaced. External data
memory interfacing is of two types i.e. RAM and ROM interfacing.
Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA
Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA
Data Memory (RAM) of 8051 Microcontroller
● In 8051 we have 128bytes of RAM.
● Address locations = 00H to 7FH
● These 128 bytes are divided into 3 different groups
128B i.e., memory addresses from 00H to 7FH is divided into Working
Registers (organized as Register Banks), Bit – Addressable Area and
General Purpose RAM (also known as Scratchpad area).
Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA
Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA
● In the 128B of RAM (from 00H to 7FH), the first 32B i.e., memory from
addresses 00H to 1FH consists of 32 Working Registers that are organized
as four banks with 8 Registers in each Bank.
● The 4 banks are named as Bank0, Bank1, Bank2 and Bank3. Each Bank
consists of 8 registers named as R0 – R7. Each Register can be addressed in
two ways: either by name or by address.
● To address the register by name, first the corresponding Bank must be
selected. In order to select the bank, we have to use the RS0 and RS1 bits of
the Program Status Word (PSW) Register (RS0 and RS1 are 3rd and 4th bits
in the PSW Register).
Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA
Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA
Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA
Question: If R7 = 5 i.e 5 is written or stored in R7. In that case where 5 will
get stored when all the banks have registers named R0- R7.
The answer is only one register bank will be active at a time. Lets say
Register Bank 1 is active and if any value is written onto R7 register then it
will get stored in the location 0FH of Bank 1
Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA
● The next 16B of the RAM i.e., from 20H to 2FH are Bit – Addressable
memory locations.
● These locations can be bit and byte addressable
● There are totally 128 bits that can be addressed individually using 00H to 7FH
or the entire byte can be addressed as 20H to 2FH.
● For example 32H represents the bit 2 of the internal RAM location 26H.
Ex: MOV A, #03H copy byte 03 to register A
MOV 26H, A copy data byte from register A to memory location 26H
SETB 32H  set to 1
CLR 32H  set to 0
Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA
Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA
● The final 80B of the internal RAM i.e., addresses from 30H to 7FH, is the
general purpose RAM area which are byte addressable.
● It is known as Read/Write Storage or scratch pad
● Used for read and write storage of data
● If we need more registers we simply use RAM locations 30H to 7FH
Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA
Program Memory (ROM) of 8051 Microcontroller
● In 8051 Microcontroller, the code or instructions to be executed are stored in the Program
Memory, which is also called as the ROM of the Microcontroller. The original 8051
Microcontroller by Intel has 4KB of internal ROM.
● In case of 4KB of Internal ROM, the address space is 0000H to 0FFFH. If the address space
i.e., the program addresses exceed this value, then the CPU will automatically fetch the code
from the external Program Memory.
● For this, the External Access Pin (EA Pin) must be pulled HIGH i.e., when the EA Pin is high,
the CPU first fetches instructions from the Internal Program Memory in the address range of
0000H to 0FFFFH.
● And if the memory addresses exceed the limit, then the instructions are fetched from the
external ROM in the address range of 1000H to FFFFH.
Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA
Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA
Register Set of 8051
Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA
Accumulator (Register A):
● It is an 8-bit register
● It is used to hold the source operand and also receives the result of the
function.
Register B:
● It is an 8bit register used as general purpose register
Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA
Program Status Word Register (PSW):
CY AC F0 RS1 RS0 OV - P
B7 B6 B5 B4 B3 B2 B1 B0
Carry Flag Auxiliary
Carry
flag
Flag 0 Register Bank
Select Signals
Overflow Flag
Parity Flag
Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA
Data Pointer (DPTR):
● It is a 16bit register used to hold a 16 bit address.
● It is used as a base register in JUMP/Lookup table instructions and external
data transmission.
Program Counter (PC):
● It is a 16 bit register used to hold the address of memory location from which
the next instruction is to be fetched.
DPH DPL
16 bit DTPR
8 bit 8 bit
Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA
Stack pointer register:
● The stack refers to an area of internal RAM that is used in conjunction with certain
opcode data to store and retrieve data quickly.
● The stack pointer register is used by the 8051 to hold the internal RAM address
that is called the top of the stack.
● The stack pointer register is 8-bit wide.
● The stack array can reside anywhere in on-chip RAM
Special Function registers:
● 8051 uses memory mapped I/O through a set of SFRs that are implemented in
the address space immediately above the 128bytes of RAM.
● All access to four I/O ports, CPU registers, interrupt-control registers,
timer/counter, UART and power control are performed through registers between
80H and FFH.
Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA
Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA
Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA
Timers & Counters
Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA
● 8051 has two timers/counters circuits which can be used either as timers or
counters.
Timer:
● To generate the time delay.
● To maintain the timing of an operation in sync with the clock.
Counter:
● To count the number of events happening outside the controller.
● Each counter may be programmed to count internal clock pulses i.e. acting as
timer or programmed to count external pulses as counter.
Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA
8051 Timers
● 8051 has two 16 bit timer registers
a) Timer 0
b) Timer 1
TL – low byte register
TH – high byte register
TH0 TL0 TH1 TL1
16 bit register 16 bit register
8bit 8bit 8bit 8bit
Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA
Registers Used in Timers/Counters
TMOD [Timer Mode] Register:
TMOD is the 8-bit special function register which is responsible for following operations.
● Select Timer 0 as a timer/counter
● Select Timer 1 as a timer/counter
● Select the mode of the timer
GATE C/T1 M1 M0 GATE C/T1 M1 M0
MSB 7 LSB 0
B6 B5 B4 B3 B2 B1
Timer 1
Timer 0
Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA
● M0 and M1 bits are used to select timer mode.
M1 M0 Operating Mode
0 0 Mode 0: 8-bit timer /counter with 5-bit prescalar
0 1
Mode1: 16–bit timer /counter
THx & TLx are cascaded
1 0 Mode 2: 8-bit auto reload timer or counter
1 1
Split timer mode: The function depends on Timer 0 and
Timer 1
Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA
C/T1
● C/T1 = 0 for selecting timer operation
● C/T1 = 1 for selecting counter operation
GATE (G): starting and stopping of timers/counters
● If G = 1 , Timer0 or Timer1 will be in Run Mode when TRX bit of TCON
register is high.
● If G= 0, Timer0 or Timer1 will be in Run Mode when TRX bit of TCON register
is high and INT0 or INT1 is high.
Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA
Timer Modes
Mode 0 : 0000 – 1FFF
● It is a 13-bit timer/ counter (8 bit timer/counter + 5 bit prescalar)
● It uses 5 bits of TL0 or TL1 and all of the 8-bits of TH0 or TH1.
Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA
Mode 1: 0000- FFFFH
● It is a 16-bit timer/counter.
● In this case every event for counter operations or machine cycles for timer
operation, the TH0– TL0 register-pair will be incremented by 1. When the
register pair overflows from FFFFH to 0000H, then the TF0 of TCON register
will be high, and it stops the timer/counter.
Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA
Mode 2: 00 – FFH
● This a 8 bit auto reload timer/counter
● In this case every event for counter operations or machine cycles for timer operation,
the TL1register will be incremented by 1. When the register pair overflows from FFH to
00H, then the TF1 of TCON register will be high, also theTL1 will be reloaded with the
content of TH1 and starts the operation again.
Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA
Mode 3: Split Timer mode
● Mode 3 is different for Timer0 and Timer1.
1) When the Timer0 is working in mode 3, the TL0 will be used as an 8-bit timer/counter. It will be
controlled by the standard Timer0 control bits, T0 and INT0 inputs.
The TH0 is used as an 8-bit timer but not the counter. This is controlled by Timer1 Control bit TR1.
When the TH0 overflows from FFH to 00H, then TF1 is set to 1. In the following diagram, we can
Timer0 in Mode 3.
2) When the Timer1 is working in Mode 3, it simply holds the count but does not run.
Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA
TCON [Timer Control] Register:
It is an 8-bit special function register used to control the following operations:
● Start and stop the Timer x (Timer 0 and Timer 1)
● To provide the status of external interrupts: INT0 & INT1
● To provide the status of overflows TF0 TF1
● To configure the interrupts either as level- triggered or edge- triggered
TF1 TR1 TF0 TR0 IE1 IT1 IE0 IT0
MSB7 B6 B5 B4 B3 B2 B1 LSB0
Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA
● TF1 – Timer 1 overflow flag
● TR1 – Timer 1 Run control bit
● TF0 – Timer 0 overflow flag
● TR0 – Timer 0 Run control bit
● IE1 – Interrupt 1 edge flag
● IT1 – Interrupt 1 type control bit
● IE0 – Interrupt 0 edge flag
● IT 0 – Interrupt 0 type control bit
Start and Stop of timers
Control external h/w interrupts
Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA
Timer/Counter Control Logic
Run Control
1= Run
0= stop
Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA
● Crystal oscillator is divided by 12 to get the operating frequency for the timer.
● If C/T = 0, it act as timer and C/T = 1 act as counter .
● We can control the timer operations by using the signals from AND gate,
where one input bit is from TR bit of TCON.
● The other input is given by the OR gate, for this OR gate there are again two
inputs given : One is from GATE bit of TMOD and the other is external
hardware interrupt INT x from TCON register.
Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA
Serial communication
Microcontroller
Peripheral
devices
Send
Receive
8051
8-bit parallel
device
Parallel to serial
Serial
Serial to parallel
Communication
Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA
Types of Serial Communication
Synchronous Asynchronous
Transmitter and receiver are
synchronized
Not synchronized
Share a common clock Separate clock
First sync character is sent and then
data
Start bit, Data , Stop bit
Block of data is transmitted
/received at a time.
Single bit is transmitted/received at
a time.
Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA
Serial Port of 8051
● The serial port of 8051 is full duplex i.e. it can transmit and receive the data
simultaneously.
● Pins used for serial communication : TxD (transmit data) & RxD (receive data)
in port 3
● Registers used in serial communication:
1) SBUF Register (serial data buffer)
2) SCON Register (serial control)
3) PCON Register (power control)
Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA
SBUF Register [Serial Data Buffer]
● SBUF is an 8-bit register is used to hold data during serial communication.
● Separate SBUF registers for transmit and receive of data.
During Transmission, SBUF register is used to
● Store the data to be transmitted via TxD pin (P3.1)
● Frame the data with start and stop bits
● Transmit the data serially through transmitted pin
During Reception
● When 8051 receives data serially via RxD pin, the start and stop bits are
separated from data in SBUF register.
Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA
Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA
SCON Register [Serial control Register]
● SCON register is an 8-bit register used to select the programmable mode of
8051.
● SM0 and SM1 are used for mode selection of SCON
SM0 SM1 SM2 REN TB8 RB8 TI RI
MSB7 LSB0
B6 B5 B4 B3 B2 B1
Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA
SM0 SM1 Programmable Mode
0 0 Mode 0: Shift register – Baude rate f/12
0 1 Mode 1: 8-bit UART – variable data rate
1 0 Mode 2: 9-bit UART – fixed data rate
1 1 Mode 3: 9-bit UART – variable data rate
Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA
SM2: Serial mode control bit
● Multiprocessor communication bit
● It is set by software to disable reception of frame
● In mode 2 & 3, if SM2 is set, will enable multiprocessor communication.
REN: Receiver enable control bit
● To enable/ disable serial data reception
TB8: Transmit bit 8
● It is set/cleared by hardware to determine state of 9th bit transmitted in 9bit UART mode.
RB8: Receive bit 8
● It is set/cleared by hardware to indicate the state of 9th bit received in mode 2 & 3
TI : Transmit interrupt flag RI: Receive interrupt flag
Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA
PCON Register [Power control Register]
● It is used for power control in 8051 microcontroller.
SMOD: Serial Bauderate Modify Bit
● To select baude rate
● SMOD = 0 at reset, baude rate equal to timer 1 rate
● SMOD = 1 by the program to double the bauderate using timer 1 in mode 1,2 &3
● Bit 7 is only used for serial communication
SMOD - - - GF1 GF0 PD IDL
MSB7 B6 B5 B4 B3 B2 B1 LSB0
Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA
● Bits 6,4,5 are reserved for future use
GF1: General purpose user flag bit 1
GF0: General purpose user flag bit 0
PD0: Power down bit
● To enter Power Down Mode, set to 1
● In the Power Down Mode, the oscillator will be stopped and the power will be reduced to 2V.
● To terminate the Power Down Mode, you have to use the Hardware Reset.
IDL: Idle mode bit
● It is set to 1 by program to enter idle mode configuration.
● To enter Idle Down Mode, set to 1
● During Idle Mode, the Microcontroller will stop the Clock Signal to the ALU (CPU) but it is
given to other peripherals like Timer, Serial, Interrupts, etc.
Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA
Operating Modes of Serial port
Mode 0: synchronous serial communication
● It uses 8-bit data
● In this mode serial data enters and exits through RxD and TxD is used for
clock signals.
● The Bauderate is fixed at 1/12th the oscillator frequency
Mode1: 8-bit UART
● In this mode 10bits are transmitted through TxD and received through RxD.
● SBUF is used to store the data
● TI/RI are set once transmission/reception is completed
Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA
● Baude rate is variable = [2SMOD /32] * Timer 1 overflow flag
Mode 2:
● In this mode 11 bits are transmitted through TxD and received through RxD
● The Bauderate is programmable to either 1/32 or 1/64 of the oscillator
frequency.
Start bit (1) 8-bit data Stop bit (1)
Start bit (1) 8-bit data Programmable
9th data bit
Stop bit (1)
Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA
Mode 3:
● It is similar to mode 2
● 11 bits are transmitted/received
● The Bauderate is variable.
Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA
Interrupts in 8051
Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA
● Interrupt is an event or signal that stops the main program temporarily and transfers the
control to an external task.
● After executing the task, the control returns to its main program.
Interrupt Sources in8051:
8051 has 5 interrupt sources
● Two external hardware interrupts
1) INT0 – External hardware interrupt 0
2) INT1 – External hardware interrupt 1
● Two timer overflow interrupts
1) TF0 – Timer 0 overflow interrupt
2) TF1 - Timer 1 overflow interrupt
● Serial Communication interrupt
1) RI/TI – Receiver/Transmit Interrupt
Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA
● The Timer and Serial interrupts are internally generated by the microcontroller, whereas
the external interrupts are generated by additional interfacing devices or switches that
are externally connected to the microcontroller.
● When an interrupt occurs, the microcontroller executes the interrupt service routine so
that memory location corresponds to the interrupt that enables it. The Interrupt
corresponding to the memory location is given in the interrupt vector table below.
Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA
Interrupt Structure of 8051 Micro controller
Registers used in Interrupt process:
1) IE (Interrupt Enable) Register
2) IP (Interrupt Priority) Register
3) TCON (Timer Control) Register
● Upon ‘RESET’ all the interrupts get disabled, and therefore, all these interrupts
must be enabled by a software. In all these five interrupts, if anyone or all are
activated, this sets the corresponding interrupt flags.
● All these interrupts can be set or cleared by bit in some special function register
that is Interrupt Enabled (IE), and this in turn depends on the priority, which is
executed by IP interrupt priority register.
Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA
Interrupt Enable Register:
● It is a bit addressable register which is responsible for enabling or disabling
the interrupts.
EA - - ES ET1 EX1 ET0 EX0
MSB7 LSB0
B6 B5 B4 B3 B2 B1
Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA
Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA
Interrupt Priority Register:
● The priority levels of the interrupts can be changed by changing the
corresponding bit in the IP register.
Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA
Timer Control Register:
● TCON register is used to specify the type of external interrupt to 8051
microcontroller.

More Related Content

Similar to MPI UNIT 5 - (INTERRUPTS OF 8086, INTRODUCTION TO 8051).pptx

With suitable diagram explain the working of 8255 a and inerrupts
With suitable diagram explain the working of 8255 a and inerruptsWith suitable diagram explain the working of 8255 a and inerrupts
With suitable diagram explain the working of 8255 a and inerruptsransherraj
 
8051 Architecture
8051 Architecture8051 Architecture
8051 ArchitectureShinuMMAEI
 
8051 microcontroller by K. Vijay Kumar
8051 microcontroller by K. Vijay Kumar8051 microcontroller by K. Vijay Kumar
8051 microcontroller by K. Vijay KumarVijay Kumar
 
4th yr dmumicrocontroller1
4th yr dmumicrocontroller14th yr dmumicrocontroller1
4th yr dmumicrocontroller1haymanotyehuala
 
Microcontroller (8051) by K. Vijay Kumar
Microcontroller (8051) by K. Vijay KumarMicrocontroller (8051) by K. Vijay Kumar
Microcontroller (8051) by K. Vijay KumarVijay Kumar
 
Introduction to 8085 Microprocessor
Introduction to 8085 MicroprocessorIntroduction to 8085 Microprocessor
Introduction to 8085 MicroprocessorRavi Anand
 
8051 microcontroller Microcontroller _2024.pptx
8051 microcontroller Microcontroller _2024.pptx8051 microcontroller Microcontroller _2024.pptx
8051 microcontroller Microcontroller _2024.pptxrohithansaliya2
 
ATmegaMicrocontrollerArchitecturenotes.pptx
ATmegaMicrocontrollerArchitecturenotes.pptxATmegaMicrocontrollerArchitecturenotes.pptx
ATmegaMicrocontrollerArchitecturenotes.pptxaartis110
 
8051 Microcontroller
8051 Microcontroller8051 Microcontroller
8051 Microcontrollerthokalpv
 
Chp4 introduction to the pic microcontroller copy
Chp4 introduction to the pic microcontroller   copyChp4 introduction to the pic microcontroller   copy
Chp4 introduction to the pic microcontroller copymkazree
 

Similar to MPI UNIT 5 - (INTERRUPTS OF 8086, INTRODUCTION TO 8051).pptx (20)

With suitable diagram explain the working of 8255 a and inerrupts
With suitable diagram explain the working of 8255 a and inerruptsWith suitable diagram explain the working of 8255 a and inerrupts
With suitable diagram explain the working of 8255 a and inerrupts
 
8051 Architecture
8051 Architecture8051 Architecture
8051 Architecture
 
8051 microcontroller by K. Vijay Kumar
8051 microcontroller by K. Vijay Kumar8051 microcontroller by K. Vijay Kumar
8051 microcontroller by K. Vijay Kumar
 
4th yr dmumicrocontroller1
4th yr dmumicrocontroller14th yr dmumicrocontroller1
4th yr dmumicrocontroller1
 
embedded system
embedded systemembedded system
embedded system
 
Architecture of 8085
Architecture of 8085Architecture of 8085
Architecture of 8085
 
Architecture of 8085
Architecture of 8085Architecture of 8085
Architecture of 8085
 
2 unit-es-printed
2 unit-es-printed2 unit-es-printed
2 unit-es-printed
 
Iot Workshop NITT 2015
Iot Workshop NITT 2015Iot Workshop NITT 2015
Iot Workshop NITT 2015
 
Microcontroller (8051) by K. Vijay Kumar
Microcontroller (8051) by K. Vijay KumarMicrocontroller (8051) by K. Vijay Kumar
Microcontroller (8051) by K. Vijay Kumar
 
Introduction to 8085 Microprocessor
Introduction to 8085 MicroprocessorIntroduction to 8085 Microprocessor
Introduction to 8085 Microprocessor
 
Embedded System
Embedded SystemEmbedded System
Embedded System
 
Atmega8u2 mur
Atmega8u2 murAtmega8u2 mur
Atmega8u2 mur
 
8051 microcontroller Microcontroller _2024.pptx
8051 microcontroller Microcontroller _2024.pptx8051 microcontroller Microcontroller _2024.pptx
8051 microcontroller Microcontroller _2024.pptx
 
ATmegaMicrocontrollerArchitecturenotes.pptx
ATmegaMicrocontrollerArchitecturenotes.pptxATmegaMicrocontrollerArchitecturenotes.pptx
ATmegaMicrocontrollerArchitecturenotes.pptx
 
8051 Microcontroller
8051 Microcontroller8051 Microcontroller
8051 Microcontroller
 
89s52 2
89s52 289s52 2
89s52 2
 
At89s51
At89s51At89s51
At89s51
 
Micro controller
Micro controllerMicro controller
Micro controller
 
Chp4 introduction to the pic microcontroller copy
Chp4 introduction to the pic microcontroller   copyChp4 introduction to the pic microcontroller   copy
Chp4 introduction to the pic microcontroller copy
 

More from RaviKiranVarma4

ppt-U3 - (Programming, Memory Interfacing).pptx
ppt-U3 - (Programming, Memory Interfacing).pptxppt-U3 - (Programming, Memory Interfacing).pptx
ppt-U3 - (Programming, Memory Interfacing).pptxRaviKiranVarma4
 
ppt-U2 - (Instruction Set of 8086, Simple programs).pptx
ppt-U2 - (Instruction Set of 8086, Simple programs).pptxppt-U2 - (Instruction Set of 8086, Simple programs).pptx
ppt-U2 - (Instruction Set of 8086, Simple programs).pptxRaviKiranVarma4
 
ppt-U1 - (Introduction to 8086, Instruction Set).pptx
ppt-U1 - (Introduction to 8086, Instruction Set).pptxppt-U1 - (Introduction to 8086, Instruction Set).pptx
ppt-U1 - (Introduction to 8086, Instruction Set).pptxRaviKiranVarma4
 
MPI UNIT 4 - (Introduction to DMA and ADC)
MPI UNIT 4 - (Introduction to DMA and ADC)MPI UNIT 4 - (Introduction to DMA and ADC)
MPI UNIT 4 - (Introduction to DMA and ADC)RaviKiranVarma4
 
An brief introduction to Deadlocks in OS
An brief introduction to Deadlocks in OSAn brief introduction to Deadlocks in OS
An brief introduction to Deadlocks in OSRaviKiranVarma4
 
PPT ON INTRODUCTION TO AI- UNIT-1-PART-1.pptx
PPT ON INTRODUCTION TO AI- UNIT-1-PART-1.pptxPPT ON INTRODUCTION TO AI- UNIT-1-PART-1.pptx
PPT ON INTRODUCTION TO AI- UNIT-1-PART-1.pptxRaviKiranVarma4
 
PPT ON INTRODUCTION TO AI- UNIT-1-PART-2.pptx
PPT ON INTRODUCTION TO AI- UNIT-1-PART-2.pptxPPT ON INTRODUCTION TO AI- UNIT-1-PART-2.pptx
PPT ON INTRODUCTION TO AI- UNIT-1-PART-2.pptxRaviKiranVarma4
 
PPT ON INTRODUCTION TO AI- UNIT-1-PART-3.pptx
PPT ON INTRODUCTION TO AI- UNIT-1-PART-3.pptxPPT ON INTRODUCTION TO AI- UNIT-1-PART-3.pptx
PPT ON INTRODUCTION TO AI- UNIT-1-PART-3.pptxRaviKiranVarma4
 
ppt on introduction to Machine learning tools
ppt on introduction to Machine learning toolsppt on introduction to Machine learning tools
ppt on introduction to Machine learning toolsRaviKiranVarma4
 
prof Elective Technical Report Writing.ppt
prof Elective Technical Report Writing.pptprof Elective Technical Report Writing.ppt
prof Elective Technical Report Writing.pptRaviKiranVarma4
 
UNIT 3.2 -Mining Frquent Patterns (part1).ppt
UNIT 3.2 -Mining Frquent Patterns (part1).pptUNIT 3.2 -Mining Frquent Patterns (part1).ppt
UNIT 3.2 -Mining Frquent Patterns (part1).pptRaviKiranVarma4
 
Harmony in the Family- Understanding the Relationship.pptx
Harmony in the Family- Understanding the Relationship.pptxHarmony in the Family- Understanding the Relationship.pptx
Harmony in the Family- Understanding the Relationship.pptxRaviKiranVarma4
 
Basic aspiration,Contineous Happiness and Prosperous- Right Understanding.pptx
Basic aspiration,Contineous Happiness and Prosperous- Right Understanding.pptxBasic aspiration,Contineous Happiness and Prosperous- Right Understanding.pptx
Basic aspiration,Contineous Happiness and Prosperous- Right Understanding.pptxRaviKiranVarma4
 
Contineous Happiness and Method of fulfillment.pptx
Contineous Happiness and Method of fulfillment.pptxContineous Happiness and Method of fulfillment.pptx
Contineous Happiness and Method of fulfillment.pptxRaviKiranVarma4
 

More from RaviKiranVarma4 (14)

ppt-U3 - (Programming, Memory Interfacing).pptx
ppt-U3 - (Programming, Memory Interfacing).pptxppt-U3 - (Programming, Memory Interfacing).pptx
ppt-U3 - (Programming, Memory Interfacing).pptx
 
ppt-U2 - (Instruction Set of 8086, Simple programs).pptx
ppt-U2 - (Instruction Set of 8086, Simple programs).pptxppt-U2 - (Instruction Set of 8086, Simple programs).pptx
ppt-U2 - (Instruction Set of 8086, Simple programs).pptx
 
ppt-U1 - (Introduction to 8086, Instruction Set).pptx
ppt-U1 - (Introduction to 8086, Instruction Set).pptxppt-U1 - (Introduction to 8086, Instruction Set).pptx
ppt-U1 - (Introduction to 8086, Instruction Set).pptx
 
MPI UNIT 4 - (Introduction to DMA and ADC)
MPI UNIT 4 - (Introduction to DMA and ADC)MPI UNIT 4 - (Introduction to DMA and ADC)
MPI UNIT 4 - (Introduction to DMA and ADC)
 
An brief introduction to Deadlocks in OS
An brief introduction to Deadlocks in OSAn brief introduction to Deadlocks in OS
An brief introduction to Deadlocks in OS
 
PPT ON INTRODUCTION TO AI- UNIT-1-PART-1.pptx
PPT ON INTRODUCTION TO AI- UNIT-1-PART-1.pptxPPT ON INTRODUCTION TO AI- UNIT-1-PART-1.pptx
PPT ON INTRODUCTION TO AI- UNIT-1-PART-1.pptx
 
PPT ON INTRODUCTION TO AI- UNIT-1-PART-2.pptx
PPT ON INTRODUCTION TO AI- UNIT-1-PART-2.pptxPPT ON INTRODUCTION TO AI- UNIT-1-PART-2.pptx
PPT ON INTRODUCTION TO AI- UNIT-1-PART-2.pptx
 
PPT ON INTRODUCTION TO AI- UNIT-1-PART-3.pptx
PPT ON INTRODUCTION TO AI- UNIT-1-PART-3.pptxPPT ON INTRODUCTION TO AI- UNIT-1-PART-3.pptx
PPT ON INTRODUCTION TO AI- UNIT-1-PART-3.pptx
 
ppt on introduction to Machine learning tools
ppt on introduction to Machine learning toolsppt on introduction to Machine learning tools
ppt on introduction to Machine learning tools
 
prof Elective Technical Report Writing.ppt
prof Elective Technical Report Writing.pptprof Elective Technical Report Writing.ppt
prof Elective Technical Report Writing.ppt
 
UNIT 3.2 -Mining Frquent Patterns (part1).ppt
UNIT 3.2 -Mining Frquent Patterns (part1).pptUNIT 3.2 -Mining Frquent Patterns (part1).ppt
UNIT 3.2 -Mining Frquent Patterns (part1).ppt
 
Harmony in the Family- Understanding the Relationship.pptx
Harmony in the Family- Understanding the Relationship.pptxHarmony in the Family- Understanding the Relationship.pptx
Harmony in the Family- Understanding the Relationship.pptx
 
Basic aspiration,Contineous Happiness and Prosperous- Right Understanding.pptx
Basic aspiration,Contineous Happiness and Prosperous- Right Understanding.pptxBasic aspiration,Contineous Happiness and Prosperous- Right Understanding.pptx
Basic aspiration,Contineous Happiness and Prosperous- Right Understanding.pptx
 
Contineous Happiness and Method of fulfillment.pptx
Contineous Happiness and Method of fulfillment.pptxContineous Happiness and Method of fulfillment.pptx
Contineous Happiness and Method of fulfillment.pptx
 

Recently uploaded

_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting DataJhengPantaleon
 
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991RKavithamani
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxRoyAbrique
 
MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docxPoojaSen20
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppCeline George
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 

Recently uploaded (20)

_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
 
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
 
MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docx
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website App
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 
Staff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSDStaff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSD
 

MPI UNIT 5 - (INTERRUPTS OF 8086, INTRODUCTION TO 8051).pptx

  • 1. Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA INTERRUPTS OF 8086, INTRODUCTION TO 8051 UNIT 5
  • 2. Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA Introduction to 8051
  • 3. Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA ● To make a complete microcomputer system, only microprocessor is not sufficient. ● It is necessary to add other peripherals such as ROM, read/write memory (RAM), decoders, drivers, number of input/output devices to make a complete microcomputer system. ● In addition special purpose devices such as interrupt controller, programmable timers, programmable i/o devices, DMA controllers may be added to improve the capability, performance and flexibility of a microcomputer system. ● The key feature of microprocessor based system is that is possible to design a system with great flexibility and possible to configure a system as large or small system by adding suitable peripherals.
  • 4. Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA ● On the other hand the microcontroller incorporates all the features that are found in microprocessor. ● However it has also added features to make a complete microcomputer system on its own. ● The microcontroller has built-in ROM, RAM, parallel I/O, serial I/O, counters and a clock circuit. ● The microcontroller has on-chip (built in) peripheral devices that make possible to have single chip microcomputer system.
  • 5. Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA Difference between Microcontroller & Microprocessor
  • 6. Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA 8051 Features ● The 8051 is an 8-bit microcontroller designed by Intel. ● It was optimized for 8-bit math and single bit Boolean operations. ● Its family MCS-51 includes 8031, 8051 and 8751 microcontrollers. ● The 8051 is an 8-bit microcontroller with 8 bit data bus and 16-bit address bus. ● The 16 bit address bus can address a 64K( 216) byte code memory space and a separate 64K byte of data memory space. ● The 8051 has 4K on-chip read only code memory and 128 bytes of internal Random Access Memory(RAM)
  • 7. Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA 8051 Features ● Besides internal RAM, the 8051 has various Special Function Registers (SFR) such as the Accumulator, the B register, and many other control registers. ● 34 8-bit general purpose registers in total. ● The ALU performs one 8-bit operation at a time. ● Two 16 bit /Counter timers ● 3 internal interrupts (one serial), 2 external interrupts. ● Four 8-bit I/O ports ● Some 8051 chips come with UART for serial communication and ADC for analog to digital conversion.
  • 8. Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA Pin Diagram
  • 9. Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA ● Pin 1 to Pin 8 (Port – 1) – Pin 1 to Pin 8 is assigned to Port 1 for simple I/O operations. These ports are work as a bidirectional port. It means all the pins of port 1 work as a input pin or output pins. If Logic 1 (one) is applied to the I/O port it will act as a input pin and if logic 0 (zero) is applied to the I/O port it will act as a output pin. ● Pin 9 (RST) – It is a reset input Pin, which is used to reset the 8051 microcontrollers to its initial values when logic 1 is applied to this pin. It is active high pin. ● Pin 10 to Pin 17 (Port-3) – Pin 10 to Pin 17 are assigned to Port 3. This port is also a bidirectional I/O port like port 1. This port performs some special functions like interrupts, control signals, timer input, serial communication etc. These are explained in detail as below.
  • 10. Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA ● P 10 (RXD) – Pin 10 is used as a RXD (serial data receive pin) which is for serial input pin. By using this input signal microcontroller receives data for serial communication. ● P 11 (TXD) – Pin 11 is used as a TXD (serial data transmit pin) which is serial output pin. By using this output signal microcontroller transmits data for serial communication. ● P 12 and P 13 (INT0′, INT1′ ) – Pins12 and 13 are used for External Hardware Interrupt 0 and Interrupt 1 respectively. When this interrupt is activated (i.e. when it is low), 8051 gets interrupted means it stopped whatever it is doing and jumps to the vector table where ISR’s (Interrupt Service Routine) are stored and starts performing Interrupt Service Routine (ISR) from that vector location.
  • 11. Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA ● P 14 and P 15 (T0 and T1) – Pin 14 and 15 are used for Timer 0 and Timer 1 external input. They can be connected with 16-bit timer/counter. ● P 16 (WR’) – Pin 16 is used for external memory write i.e. writing data to the external memory. ● P 17 (RD’) – Pin 17 is used for external memory read i.e. reading data from external memory. ● Pin 18 and Pin 19 (XTAL2 And XTAL1) –Pins 18 and 19 i.e. XTAL 2 and XTAL 1 are the pins for interfacing external oscillator. Mostly, a Quartz Crystal Oscillator is connected here to get the system clock.
  • 12. Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA ● Pin 20 (GND) – Pin 20 is the Ground Pin. It is connected to the 0V (negative terminal) of the Power Supply. ● Pin 21 to Pin28 (Port 2) – Pin 21 to pin 28 are Port 2 pins. Port 2 is also a bidirectional Input /Output port i.e. all pins of port 2 work as a input pin or as a output pins. But, this is only possible when we are not using any external memory. If we use external memory, then these pins will work as high order address bus (A8 to A15). ● Pin 29 (PSEN) – The Pin 29 is the Program Strobe Enable Pin (PSEN). It is used to enable external program memory and read a signal from the external program memory. ● Pin 30 (ALE) – Pin 30 is the Address Latch Enable Pin. This pin is used to enable or disable the external memory interfacing.
  • 13. Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA ● Pin 31 (EA) – Pin 31 is the External Access Enable (EA) Pin. This pin allows external Program Memory. It is an input pin and connected from VCC or GND. If we want to access the program from external program memory, it must be connected with GND. If we want to use on-chip memory, it must be high (connected with VCC). ● Pin 32 to Pin 39 (Port 0) – Pin 32 to Pin 39 are Port 0 pins. When we don’t use any external memory, these pins are used as a bidirectional pin like port 2 and port 3. But, when ALE or Pin 30 is at 1, then this port is used as data bus. And when the ALE pin is at 0, then this port is used as a lower order address bus (A0 to A7). ● Pin 40 (VCC) – This pin is used to provide (+5v ) power supply to the 8051 microcontroller circuit.
  • 14. Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA 8051 Microcontroller Basic Circuit
  • 15. Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA Architecture of 8051
  • 16. Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA
  • 17. Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA Functional Units: ● Central Processing Unit (CPU) ● Memory – 128bytes RAM & 4kB ROM ● I/O ports ● Special Function Registers ● Serial Port Central processing Unit: ● ALU ● Registers – A,B, PSW, temporary registers ● 16 bit program counter (PC) ● Data pointer (DPTR) & Stack pointer (SP)
  • 18. Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA Arithmetic Logic Unit (ALU): ● It can perform 8-bit arithmetic operations ● It can also manipulate one bit and 8bit logical operations. Accumulator (Register A): ● It is an 8-bit register ● It is used to hold the source operand and also receives the result of the function. Register B: ● It is an 8bit register used as general purpose register Special Function Register (SFR): ● In 8051, access to the I/O ports, CPU registers, Timer/counter, Logic control registers can be done through the SFRs (located from 80H to FFH).
  • 19. Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA Program Status Word Register (PSW): CY AC F0 RS1 RS0 OV - P B7 B6 B5 B4 B3 B2 B1 B0 Carry Flag Auxiliary Carry flag Flag 0 Register Bank Select Signals Overflow Flag Parity Flag
  • 20. Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA Data Pointer (DPTR): ● It is a 16bit register used to hold a 16 bit address. ● It is used as a base register in JUMP/Lookup table instructions and external data transmission. Program Counter (PC): ● It is a 16 bit register used to hold the address of memory location from which the next instruction is to be fetched. DPH DPL 16 bit DTPR 8 bit 8 bit
  • 21. Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA System Bus: ● The system bus consists of an 8-bit data bus, 16-bit address bus and control signals. ● It is used to connect all the internal devices to the CPU. I/O ports: ● 8051 has 32 bidirectional I/O pins which are organized as four parallel 8-bit I/O ports. Port 0 : I/O ports & multiplexed AD0 – AD7 Port 1 : Only for I/O Port 2 : I/O ports & Higher – order Address A8- A15 Port 3 : I/O ports & multifunctional
  • 22. Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA Serial Port: ● The serial port of 8051 is full-duplex i.e. it can transmit and receive from/to an external device. ● Used for serial communication Memory: ● For operation Micro-controller required a program. This program guides the microcontroller to perform the specific tasks. This program installed in microcontroller required some on chip memory for the storage of the program. ● Microcontroller also required memory for storage of data and operands for the short duration. ● In microcontroller 8051 there is code or program memory of 4 KB that is it has 4 KB ROM and it also comprise of data memory (RAM) of 128 bytes.
  • 23. Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA Interrupt: ● 8051 provides 5 interrupt sources ● External hardware interrupts : INT0, INT1 ● External Timer Interrupts : TF0, TF1 ● Serial Communication Interrupt : RI/ TI Oscillator: ● A clock signal allows the operations inside the microcontroller and other parts to be synchronous. ● A Clock Generator is an integral part of the Microcontroller’s Architecture and the user has to provide an additional Timing Circuit in the form of a Crystal.
  • 24. Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA 8051 Memory Organization
  • 25. Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA ● The 8051 microcontroller's memory is divided into Program Memory and Data Memory. Program Memory (ROM) is used for permanent saving program being executed, while Data Memory (RAM) is used for temporarily storing and keeping intermediate results and variables. 1.Program memory: (4kB ROM) ● Program memory accessed through EA pin. In program memory two categories takes place: a)If EA is high, internal program memory is accessed up to 0FFFH memory location and external program memory accessed from 1000H to FFFFH memory locations. b)If EA is low, only external program memory accessed from 0000H to FFFFH memory locations.
  • 26. Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA
  • 27. Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA 2.Data memory: ● Data memory is used to store the memory in the registers each of 64k bytes size, to access the data memory instruction MOVX is used. Data memory is of two types Internal and external. i) Internal data memory: ● The internal data memory consists of 256 bytes, these are divided into two parts: a) 00H-7FH for internal data RAM (lower 128 bytes) b) 80H-FFH for special function registers (upper 128 bytes) ii) External data memory: ● The 8051 gives the facility to interface external RAM and ROM. External RAM is accessed by DPTR and up to 64KB of RAM can be interfaced. External data memory interfacing is of two types i.e. RAM and ROM interfacing.
  • 28. Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA
  • 29. Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA Data Memory (RAM) of 8051 Microcontroller ● In 8051 we have 128bytes of RAM. ● Address locations = 00H to 7FH ● These 128 bytes are divided into 3 different groups 128B i.e., memory addresses from 00H to 7FH is divided into Working Registers (organized as Register Banks), Bit – Addressable Area and General Purpose RAM (also known as Scratchpad area).
  • 30. Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA
  • 31. Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA ● In the 128B of RAM (from 00H to 7FH), the first 32B i.e., memory from addresses 00H to 1FH consists of 32 Working Registers that are organized as four banks with 8 Registers in each Bank. ● The 4 banks are named as Bank0, Bank1, Bank2 and Bank3. Each Bank consists of 8 registers named as R0 – R7. Each Register can be addressed in two ways: either by name or by address. ● To address the register by name, first the corresponding Bank must be selected. In order to select the bank, we have to use the RS0 and RS1 bits of the Program Status Word (PSW) Register (RS0 and RS1 are 3rd and 4th bits in the PSW Register).
  • 32. Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA
  • 33. Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA
  • 34. Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA Question: If R7 = 5 i.e 5 is written or stored in R7. In that case where 5 will get stored when all the banks have registers named R0- R7. The answer is only one register bank will be active at a time. Lets say Register Bank 1 is active and if any value is written onto R7 register then it will get stored in the location 0FH of Bank 1
  • 35. Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA ● The next 16B of the RAM i.e., from 20H to 2FH are Bit – Addressable memory locations. ● These locations can be bit and byte addressable ● There are totally 128 bits that can be addressed individually using 00H to 7FH or the entire byte can be addressed as 20H to 2FH. ● For example 32H represents the bit 2 of the internal RAM location 26H. Ex: MOV A, #03H copy byte 03 to register A MOV 26H, A copy data byte from register A to memory location 26H SETB 32H  set to 1 CLR 32H  set to 0
  • 36. Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA
  • 37. Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA ● The final 80B of the internal RAM i.e., addresses from 30H to 7FH, is the general purpose RAM area which are byte addressable. ● It is known as Read/Write Storage or scratch pad ● Used for read and write storage of data ● If we need more registers we simply use RAM locations 30H to 7FH
  • 38. Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA Program Memory (ROM) of 8051 Microcontroller ● In 8051 Microcontroller, the code or instructions to be executed are stored in the Program Memory, which is also called as the ROM of the Microcontroller. The original 8051 Microcontroller by Intel has 4KB of internal ROM. ● In case of 4KB of Internal ROM, the address space is 0000H to 0FFFH. If the address space i.e., the program addresses exceed this value, then the CPU will automatically fetch the code from the external Program Memory. ● For this, the External Access Pin (EA Pin) must be pulled HIGH i.e., when the EA Pin is high, the CPU first fetches instructions from the Internal Program Memory in the address range of 0000H to 0FFFFH. ● And if the memory addresses exceed the limit, then the instructions are fetched from the external ROM in the address range of 1000H to FFFFH.
  • 39. Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA
  • 40. Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA Register Set of 8051
  • 41. Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA Accumulator (Register A): ● It is an 8-bit register ● It is used to hold the source operand and also receives the result of the function. Register B: ● It is an 8bit register used as general purpose register
  • 42. Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA Program Status Word Register (PSW): CY AC F0 RS1 RS0 OV - P B7 B6 B5 B4 B3 B2 B1 B0 Carry Flag Auxiliary Carry flag Flag 0 Register Bank Select Signals Overflow Flag Parity Flag
  • 43. Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA Data Pointer (DPTR): ● It is a 16bit register used to hold a 16 bit address. ● It is used as a base register in JUMP/Lookup table instructions and external data transmission. Program Counter (PC): ● It is a 16 bit register used to hold the address of memory location from which the next instruction is to be fetched. DPH DPL 16 bit DTPR 8 bit 8 bit
  • 44. Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA Stack pointer register: ● The stack refers to an area of internal RAM that is used in conjunction with certain opcode data to store and retrieve data quickly. ● The stack pointer register is used by the 8051 to hold the internal RAM address that is called the top of the stack. ● The stack pointer register is 8-bit wide. ● The stack array can reside anywhere in on-chip RAM Special Function registers: ● 8051 uses memory mapped I/O through a set of SFRs that are implemented in the address space immediately above the 128bytes of RAM. ● All access to four I/O ports, CPU registers, interrupt-control registers, timer/counter, UART and power control are performed through registers between 80H and FFH.
  • 45. Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA
  • 46. Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA
  • 47. Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA Timers & Counters
  • 48. Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA ● 8051 has two timers/counters circuits which can be used either as timers or counters. Timer: ● To generate the time delay. ● To maintain the timing of an operation in sync with the clock. Counter: ● To count the number of events happening outside the controller. ● Each counter may be programmed to count internal clock pulses i.e. acting as timer or programmed to count external pulses as counter.
  • 49. Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA 8051 Timers ● 8051 has two 16 bit timer registers a) Timer 0 b) Timer 1 TL – low byte register TH – high byte register TH0 TL0 TH1 TL1 16 bit register 16 bit register 8bit 8bit 8bit 8bit
  • 50. Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA Registers Used in Timers/Counters TMOD [Timer Mode] Register: TMOD is the 8-bit special function register which is responsible for following operations. ● Select Timer 0 as a timer/counter ● Select Timer 1 as a timer/counter ● Select the mode of the timer GATE C/T1 M1 M0 GATE C/T1 M1 M0 MSB 7 LSB 0 B6 B5 B4 B3 B2 B1 Timer 1 Timer 0
  • 51. Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA ● M0 and M1 bits are used to select timer mode. M1 M0 Operating Mode 0 0 Mode 0: 8-bit timer /counter with 5-bit prescalar 0 1 Mode1: 16–bit timer /counter THx & TLx are cascaded 1 0 Mode 2: 8-bit auto reload timer or counter 1 1 Split timer mode: The function depends on Timer 0 and Timer 1
  • 52. Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA C/T1 ● C/T1 = 0 for selecting timer operation ● C/T1 = 1 for selecting counter operation GATE (G): starting and stopping of timers/counters ● If G = 1 , Timer0 or Timer1 will be in Run Mode when TRX bit of TCON register is high. ● If G= 0, Timer0 or Timer1 will be in Run Mode when TRX bit of TCON register is high and INT0 or INT1 is high.
  • 53. Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA Timer Modes Mode 0 : 0000 – 1FFF ● It is a 13-bit timer/ counter (8 bit timer/counter + 5 bit prescalar) ● It uses 5 bits of TL0 or TL1 and all of the 8-bits of TH0 or TH1.
  • 54. Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA Mode 1: 0000- FFFFH ● It is a 16-bit timer/counter. ● In this case every event for counter operations or machine cycles for timer operation, the TH0– TL0 register-pair will be incremented by 1. When the register pair overflows from FFFFH to 0000H, then the TF0 of TCON register will be high, and it stops the timer/counter.
  • 55. Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA Mode 2: 00 – FFH ● This a 8 bit auto reload timer/counter ● In this case every event for counter operations or machine cycles for timer operation, the TL1register will be incremented by 1. When the register pair overflows from FFH to 00H, then the TF1 of TCON register will be high, also theTL1 will be reloaded with the content of TH1 and starts the operation again.
  • 56. Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA Mode 3: Split Timer mode ● Mode 3 is different for Timer0 and Timer1. 1) When the Timer0 is working in mode 3, the TL0 will be used as an 8-bit timer/counter. It will be controlled by the standard Timer0 control bits, T0 and INT0 inputs. The TH0 is used as an 8-bit timer but not the counter. This is controlled by Timer1 Control bit TR1. When the TH0 overflows from FFH to 00H, then TF1 is set to 1. In the following diagram, we can Timer0 in Mode 3. 2) When the Timer1 is working in Mode 3, it simply holds the count but does not run.
  • 57. Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA TCON [Timer Control] Register: It is an 8-bit special function register used to control the following operations: ● Start and stop the Timer x (Timer 0 and Timer 1) ● To provide the status of external interrupts: INT0 & INT1 ● To provide the status of overflows TF0 TF1 ● To configure the interrupts either as level- triggered or edge- triggered TF1 TR1 TF0 TR0 IE1 IT1 IE0 IT0 MSB7 B6 B5 B4 B3 B2 B1 LSB0
  • 58. Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA ● TF1 – Timer 1 overflow flag ● TR1 – Timer 1 Run control bit ● TF0 – Timer 0 overflow flag ● TR0 – Timer 0 Run control bit ● IE1 – Interrupt 1 edge flag ● IT1 – Interrupt 1 type control bit ● IE0 – Interrupt 0 edge flag ● IT 0 – Interrupt 0 type control bit Start and Stop of timers Control external h/w interrupts
  • 59. Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA Timer/Counter Control Logic Run Control 1= Run 0= stop
  • 60. Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA ● Crystal oscillator is divided by 12 to get the operating frequency for the timer. ● If C/T = 0, it act as timer and C/T = 1 act as counter . ● We can control the timer operations by using the signals from AND gate, where one input bit is from TR bit of TCON. ● The other input is given by the OR gate, for this OR gate there are again two inputs given : One is from GATE bit of TMOD and the other is external hardware interrupt INT x from TCON register.
  • 61. Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA Serial communication Microcontroller Peripheral devices Send Receive 8051 8-bit parallel device Parallel to serial Serial Serial to parallel Communication
  • 62. Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA Types of Serial Communication Synchronous Asynchronous Transmitter and receiver are synchronized Not synchronized Share a common clock Separate clock First sync character is sent and then data Start bit, Data , Stop bit Block of data is transmitted /received at a time. Single bit is transmitted/received at a time.
  • 63. Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA Serial Port of 8051 ● The serial port of 8051 is full duplex i.e. it can transmit and receive the data simultaneously. ● Pins used for serial communication : TxD (transmit data) & RxD (receive data) in port 3 ● Registers used in serial communication: 1) SBUF Register (serial data buffer) 2) SCON Register (serial control) 3) PCON Register (power control)
  • 64. Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA SBUF Register [Serial Data Buffer] ● SBUF is an 8-bit register is used to hold data during serial communication. ● Separate SBUF registers for transmit and receive of data. During Transmission, SBUF register is used to ● Store the data to be transmitted via TxD pin (P3.1) ● Frame the data with start and stop bits ● Transmit the data serially through transmitted pin During Reception ● When 8051 receives data serially via RxD pin, the start and stop bits are separated from data in SBUF register.
  • 65. Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA
  • 66. Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA SCON Register [Serial control Register] ● SCON register is an 8-bit register used to select the programmable mode of 8051. ● SM0 and SM1 are used for mode selection of SCON SM0 SM1 SM2 REN TB8 RB8 TI RI MSB7 LSB0 B6 B5 B4 B3 B2 B1
  • 67. Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA SM0 SM1 Programmable Mode 0 0 Mode 0: Shift register – Baude rate f/12 0 1 Mode 1: 8-bit UART – variable data rate 1 0 Mode 2: 9-bit UART – fixed data rate 1 1 Mode 3: 9-bit UART – variable data rate
  • 68. Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA SM2: Serial mode control bit ● Multiprocessor communication bit ● It is set by software to disable reception of frame ● In mode 2 & 3, if SM2 is set, will enable multiprocessor communication. REN: Receiver enable control bit ● To enable/ disable serial data reception TB8: Transmit bit 8 ● It is set/cleared by hardware to determine state of 9th bit transmitted in 9bit UART mode. RB8: Receive bit 8 ● It is set/cleared by hardware to indicate the state of 9th bit received in mode 2 & 3 TI : Transmit interrupt flag RI: Receive interrupt flag
  • 69. Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA PCON Register [Power control Register] ● It is used for power control in 8051 microcontroller. SMOD: Serial Bauderate Modify Bit ● To select baude rate ● SMOD = 0 at reset, baude rate equal to timer 1 rate ● SMOD = 1 by the program to double the bauderate using timer 1 in mode 1,2 &3 ● Bit 7 is only used for serial communication SMOD - - - GF1 GF0 PD IDL MSB7 B6 B5 B4 B3 B2 B1 LSB0
  • 70. Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA ● Bits 6,4,5 are reserved for future use GF1: General purpose user flag bit 1 GF0: General purpose user flag bit 0 PD0: Power down bit ● To enter Power Down Mode, set to 1 ● In the Power Down Mode, the oscillator will be stopped and the power will be reduced to 2V. ● To terminate the Power Down Mode, you have to use the Hardware Reset. IDL: Idle mode bit ● It is set to 1 by program to enter idle mode configuration. ● To enter Idle Down Mode, set to 1 ● During Idle Mode, the Microcontroller will stop the Clock Signal to the ALU (CPU) but it is given to other peripherals like Timer, Serial, Interrupts, etc.
  • 71. Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA Operating Modes of Serial port Mode 0: synchronous serial communication ● It uses 8-bit data ● In this mode serial data enters and exits through RxD and TxD is used for clock signals. ● The Bauderate is fixed at 1/12th the oscillator frequency Mode1: 8-bit UART ● In this mode 10bits are transmitted through TxD and received through RxD. ● SBUF is used to store the data ● TI/RI are set once transmission/reception is completed
  • 72. Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA ● Baude rate is variable = [2SMOD /32] * Timer 1 overflow flag Mode 2: ● In this mode 11 bits are transmitted through TxD and received through RxD ● The Bauderate is programmable to either 1/32 or 1/64 of the oscillator frequency. Start bit (1) 8-bit data Stop bit (1) Start bit (1) 8-bit data Programmable 9th data bit Stop bit (1)
  • 73. Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA Mode 3: ● It is similar to mode 2 ● 11 bits are transmitted/received ● The Bauderate is variable.
  • 74. Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA Interrupts in 8051
  • 75. Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA ● Interrupt is an event or signal that stops the main program temporarily and transfers the control to an external task. ● After executing the task, the control returns to its main program. Interrupt Sources in8051: 8051 has 5 interrupt sources ● Two external hardware interrupts 1) INT0 – External hardware interrupt 0 2) INT1 – External hardware interrupt 1 ● Two timer overflow interrupts 1) TF0 – Timer 0 overflow interrupt 2) TF1 - Timer 1 overflow interrupt ● Serial Communication interrupt 1) RI/TI – Receiver/Transmit Interrupt
  • 76. Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA ● The Timer and Serial interrupts are internally generated by the microcontroller, whereas the external interrupts are generated by additional interfacing devices or switches that are externally connected to the microcontroller. ● When an interrupt occurs, the microcontroller executes the interrupt service routine so that memory location corresponds to the interrupt that enables it. The Interrupt corresponding to the memory location is given in the interrupt vector table below.
  • 77. Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA Interrupt Structure of 8051 Micro controller Registers used in Interrupt process: 1) IE (Interrupt Enable) Register 2) IP (Interrupt Priority) Register 3) TCON (Timer Control) Register ● Upon ‘RESET’ all the interrupts get disabled, and therefore, all these interrupts must be enabled by a software. In all these five interrupts, if anyone or all are activated, this sets the corresponding interrupt flags. ● All these interrupts can be set or cleared by bit in some special function register that is Interrupt Enabled (IE), and this in turn depends on the priority, which is executed by IP interrupt priority register.
  • 78. Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA Interrupt Enable Register: ● It is a bit addressable register which is responsible for enabling or disabling the interrupts. EA - - ES ET1 EX1 ET0 EX0 MSB7 LSB0 B6 B5 B4 B3 B2 B1
  • 79. Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA
  • 80. Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA Interrupt Priority Register: ● The priority levels of the interrupts can be changed by changing the corresponding bit in the IP register.
  • 81. Prepared by M.V.Bhuvaneswari, Asst.Prof, CSE,MVGRA Timer Control Register: ● TCON register is used to specify the type of external interrupt to 8051 microcontroller.

Editor's Notes

  1. Microcomputer is a system that includes a minimum of a microprocessor, program memory, data memory and I/O. Some also include additional components such as timers, counters, ADCs and so on.
  2. Popular examples of the microprocessor are Intel Core i7, AMD Athlon, Broadcom BCM2711 (Raspberry Pi) etc. Some examples of microcontrollers are ATmega328 (Arduino UNO), STM32 etc
  3. A UART (Universal Asynchronous receiver-transmitter) is usually an individual (or part of an) integrated circuit (IC) used for serial communications over a computer or peripheral device serial port. 
  4. External memory enables users to store data separately from a computer’s main or primary storage and memory at relatively low cost. Ex: CDs, DVDs, USB drives etc. XTAL stands for external oscillator. There are two pins XTAL 1 and XTAL2 for connecting the two pins of crystal oscillator with two ceramic capacitor of 33pf to provide clock to the MCU
  5. This memory type saves the executed code of a program permanently. Default size of the memory on chip is 4K; however, depending on the requirement, you can add external memory upto 60K in size. Thus, total Program Memory available on 8051 Microcontroller is 64K in size. The transfer process of executed program from default to external memory is automatic in nature. You must also note that handling of external memory is decided by the logic state of EA (External Access) pin.
  6. A prescalar is more like a multiplier or a step for incrementing the timer. Normally the timer will increment for every clock cycle. Instead we can use prescalar to increment it every 2 clock cycle once or 4 clock cycle once etc. The purpose of the prescaler is to allow the timer to be clocked at the rate a user desires. For shorter (8 and 16-bit) timers, there will often be a tradeoff between resolution (high resolution requires a high clock rate) and range (high clock rates cause the timer to overflow more quickly).  Common fixed-integer microwave prescalers are available in modulus 2, 4, 8, 5 and 10, and can operate at frequencies in excess of 10 GHz
  7. In a sequential circuit, if the output changes when the signal transits from a high level to a low level or from a low level to a high level, we call it edge triggering. Here, the edge that changes the voltage from low level to the high level is called rising edge (positive edge). And, the edge that changes the voltage from high level to the low level is called falling edge (negative edge). In the sequential circuit, if the output changes during the high voltage period or low voltage period, it is called level triggering. In other words, the output changes during either high voltage or low voltage period- not during the edges like in edge triggering. Interrupts in 8051 microcontroller are more desirable to reduce the regular status checking of the interfaced devices or inbuilt devices. Interrupt is an event that temporarily suspends the main program, passes the control to a special code section, executes the event-related function and resumes the main program flow where it had left off.
  8. In serial communication one bit at a time is transferred through a single line. In parallel communication all bits are transmitted simultaneously through many number of lines.
  9. Baude rate defines the bits transmitted per second.
  10. UART – Universal Asynchronous Receiver Transmitter
  11. 8051 operates in multiprocessor mode for serial communication Mode-2 and Mode-3. In multiprocessor mode, a Master processor can communicate with more than one slave processors.  The Master communicates with one slave at a time. 11 bits are transmitted by the Master, viz, One start bit (usually '0'), 8 data bits (LSB first), TB8 and a stop bit (usually '1'). TB8 is '1' for an address byte and '0' for a data byte. If the Master wants to communicate with certain slave, it first sends the address of the slave with TB8=1. This address is received by all the slaves. Slaves initially have their SM2 bit set to '1'. All slaves check this address and the slave who is being addressed, responds by clearing its SM2 bit to '0' so that the data bytes can be received. The 9th bit is a programmable bit and it is given through TB8. Here 9th bit is 1 and it is used for error checking and stop bit for triggering the data high ( so start bit gets 0 and so on ). Why the 9th bit , when the already stop bit exists? Standard value of 9th bit is 1 and can be made 0. Whenever SM2 = 1( receiver accepts only errorless data ) and if 9th bit is 1, then only errorless data is accepted or else discarded. Discarding data is a purpose.