0% found this document useful (0 votes)
24 views26 pages

MODULE-5 (Interrupts & Interfacing)

Uploaded by

Shashank Patgar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views26 pages

MODULE-5 (Interrupts & Interfacing)

Uploaded by

Shashank Patgar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 26

Module-5

8051 Interrupts and


Interfacing Applications
Interrupt
 During program execution, if peripheral device needs
service from microcontroller then the peripheral
device will generate interrupt and gets the service
from microcontroller.

 When peripheral device activates the interrupt signal,


the controller jumps to Interrupt Service Routine (ISR)
or Interrupt Handler.

 ISR are the short programs written at some other


memory location other than the main program.

 The group of memory locations set aside to hold the


address of ISRs is called Interrupt Vector Table.
Polling Method Interrupt Method
1) Lot of microcontroller 1) Microcontroller time &
processing power is
power are not wasted
wasted in checking
whether I/O devices need
service 2)It assigns priority to
2) Since all the devices are peripheral device service
polled in a sequential request
manner, there is no
3)Microcontroller can ignore
priority mechanism
(mask) a device request for
3) There is no possibility of
service
ignoring a device request
for service 4)Efficient way of handing I/O
4) Inefficient way of handling devices
I/O devices 5)External hardware signal is
5)No external hardware signal required to interrupt
required microcontroller
Steps in executing an Interrupt
1)Microcontroller completes the execution of the
current instruction & saves the address of the next
instruction ie., the contents of PC on the stack.

2) It also saves the current status of all the


interrupts internally ie., not on the stack.

3) It jumps to a fixed location in memory called


Interrupt Vector Table (IVT) that holds the address
of the Interrupt Service Routine.
4) The microcontroller gets the address of ISR
from IVT & transfers program control to the
ISR. It executes instructions within the ISR in
sequence till it reaches the RETI (Return from
Interrupt) instruction.

5) After executing RETI instruction, it gets PC


address from stack by popping two bytes of
stack into PC & it starts to execute from that
address.
Interrupt Service Routine Processing
Classification of Interrupts

 External Interrupts (Hardware Interrupts)


 Internal Interrupts ( Software Interrupts)
 Maskable Interrupts
 Non-maskable Interrupts
 Vectored Interrupts
 Non-Vectored Interrupts
External / Hardware Interrupts
These are initiated by peripheral devices
through external pins of the microcontroller.

Internal / Software Interrupts


These are activated by internal peripherals of
microcontroller like Timer/Counter or serial
port through special instructions in the
program.
Maskable Interrupts
These can be disabled by the microcontroller
using program.
When masked, microcontroller does not
respond to the interrupt even though the
interrupt is activated.

Non- maskable Interrupt


These interrupts can not be disabled by the
program.
Vectored Interrupts
The starting address of the Interrupt Service
Routine (ISR ) is predefined.
Therefore interrupt response time is less
compared to non-vectored interrupts.
Non- vectored Interrupts
The starting address of the Interrupt Service
Routine (ISR) is not predefined.
It is provided by the external peripheral device
Five Interrupts (Maskable & Vectored
Interrupts) :-
 External interrupts(INT0,INT1)
 Internal interrupts( TF0, TF1, TI, RI)
External Hardware Interrupt 0 (INT0) 0003 (Highest)

Timer 0 Interrupt (TF0) 000B

External Hardware Interrupt 1 (INT1) 0013

Timer 1 Interrupt (TF1) 001B

Serial Interrupt ( RI and TI ) 0023 (Lowest)


Interrupt Enable (IE)– Bit addressable –0A8h

EA - ET 2 ES ET 1 EX1 ET 0 EX 0

IE.7 - EA - Disables all interrupts


EA = 0 – No interrupt is acknowledged
EA= 1 – Each interrupt source is individually
enabled or disabled by setting or clearing its
enable bit
IE.6 – Not implemented
IE.5 – ET 2
Enables/disables Timer 2 overflow interrupt (8052 only)
IE.4 – ES
Enables /disables the serial port interrupt (RI, TI)
IE.3 – ET1
Enables/disables Timer 1 overflow interrupt(TF1)
IE.2- EX1
Enables /disables external Interrupt 1 (INT 1)
IE.1- ET 0
Enables/disables Timer 0 overflow interrupt ( TF0)
IE.0-EX0
Enables/disables external Interrupt 0 (INT O)
Interrupt Priority ( IP)- Bit addressable– 0B8h
- - PT 2 PS PT 1 PX 1 PT 0 PX 0

Priority bit =1 ---High , Priority bit=0 -----Low priority


IP.7 – Not implemented
IP.6 - Not implemented
IP.5 - PT2 - Timer 2 Interrupt priority bit (8052 only)
IP.4 – PS -Serial port interrupt priority bit (RI , TI)
IP.3 – PT 1 -Timer 1 interrupt priority bit (TF1)
IP.2-PX1 – External interrupt 1 priority bit(INT 1)
IP.1- PT 0 - Timer 0 interrupt priority bit (TF 0)
IP.0- PX0 – External interrupt 0 priority bit (INT 0)
Interfacing 8051 to LED
Sourcing current
 The maximum current that the 8051 port pin can
supply to drive an externally connected device
(LED / Buzzer / TTL logic device)
For TTL family of 8051 devices the sourcing current is
approximately 60 µA.
Sinking current
The maximum current that the 8051 port pin can
absorb through the device which is connected to an
external supply.
Port 1,2,3 pins current sink = 1.6mA; Port 0 =3.2mA
 A typical LED consumes 10 – 15 mA .Thus we cannot
drive LED in current source mode.
 However it can be driven in Current sink mode. But
the brightness of LED is poor.
 Driver transistor can be used to solve the
problem of Current Sourcing & Sinking by
amplifying the current.
1) Write an ALP to flash LED connected to port P2.0
ORG 0000H ORG 0000H
BACK: SETB P2.0 BACK: CPL P2.0
ACALL DELAY ACALL DELAY
CLR P2.0 SJMP BACK
ACALL DELAY DELAY: M0V R1,#30H
SJMP BACK HERE: DJNZ R1,HERE

DELAY: MOV R1,#30H NOP


HERE : DJNZ R1,HERE NOP
NOP RET
NOP
RET
2) A switch is connected to P1.7.Write ALP to check
status of switch SW & perform the following:
(a) If SW = 0 , send letter “N” to P2
(b) If SW=1 , send letter “ Y” to P2
ORG 0000H
SETB P1.7
AGAIN: JB P1.7, OVER
MOV P2, # ‘N’
SJMP AGAIN
OVER: MOV P2, # ‘Y’
SJMP AGAIN
3) A switch is connected to P1.0 and LED to P2.7.Write
ALP to get the status of the switch & send it to LED.
ORG 0000H
SETB P1.0
AGAIN : MOV C, P1.0
MOV P2.7, C
SJMP AGAIN

NOTE : MOV P2.7 , P1.0 ---------Invalid


MOV P2,P1----------------Valid
Interfacing 8051 to ADC-0804
ADC-0804 IC
Features :
8-bit parallel ADC in the family of ADC-0800 from
National Semiconductor
Operates on single +5V power supply
8-bits resolution
Conversion time 110µs
Access time 135ns
It has on –chip clock generator
Does not require zero adjustment
Output meets TTL voltage level specifications
Steps in data conversion by ADC-0804
1) Make low to high pulse to pin WR to start the
conversion.
2) Keep monitoring the INTR pin. If INTR is low,
the conversion is finished and we can go to
next step. If INTR is high, keep polling until it
goes low.
3) After INTR has become low, make high to
low pulse to the RD pin to get the data out of
the ADC-0804 IC chip.
Analog to Digital Conversion Program

MOV P1, #0FFH; Configure as input port


BACK: CLR P2.6 ; Make WR =0 and
SETB P2.6 ; Make WR=1 start conversion
AGAIN: JB P2.7, AGAIN ;Wait for end of conversion
CLR P2.5 ; Enable read
MOV A, P1 ; Read data through Port 1
SETB P2.5 ; Disable read after reading data
SJMP BACK ; go for next conversion cycle

You might also like

pFad - Phonifier reborn

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

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


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy