You are on page 1of 17

Microprocessors and Microcontrollers – 11EC311

Interrupts in 8051

Introduction 01/09/15 8051 Interrupts .Copyleft 2 .

Copyleft 3 . it does jobs until Interrupt Occurs and then not do anything except wait processes ISR Polling cannot assign priority as it Interrupts can assign priority among works in round-robin mechanism devices Cannot Ignore(Mask) a device We can Ignore(Mask) an Interrupt 01/09/15 8051 Interrupts .Polling vs Interrupts Polling Driven Mechanism Interrupt Driven Mechanism Microcontroller continuously Monitors Device notifies the Controller by the status of device sending an Interrupt Signal Microntroller job is to wait for the event Microcontroller keep on doing another to occur to serve the device.

● Finishes the currently executing instruction ● PUSHes PC(Program Counter) on Stack (Low Byte First) ● Saves status of Interrupts Internally(Not on Stack) ● Gets the address of ISR(Interrupt Service Routine) and loads into PC from IVT(Interrupt Vector Table) ● Continues executing ISR until RETI is Executed ● POPs back PC From Stack and continues execution 01/09/15 8051 Interrupts .Steps in Executing an Interrupt When an Interrupt Occurs the Microcontroller.Copyleft 4 .

Copyleft 5 .Interrupt Vector Table (IVT) 01/09/15 8051 Interrupts .

IE(Interrupt Enable) Register 01/09/15 8051 Interrupts .Copyleft 6 .

Copyleft 7 .Programming Timer Interrupts ● Progarm IE Register to enable Timer Interrupt ● Store the program to run after Timer Overflow occurs in IVT Address of Timer ● 000B for Timer 0 ● 001B for Timer 1 ● Use Ljmp or sjmp to avoid overwriting the main code in IVT Address Space. 01/09/15 8051 Interrupts .

AVOIDING OVERLAP ON IVT ORG 000BH .#02H MOV TH0. RESET SJMP MAIN .Example – Timer Interrupts Generate Sqaure Wave of 10Khz in Timer 0 Mode 2 ORG 0000H .#9CH MOV IE.Copyleft 8 . TIMER 0 INTERRUPT VECTOR CPL P1.ENABLE TIMER0 INTERRUPT SETB TR0 SJMP $ 01/09/15 8051 Interrupts .#82H .2 RETI ORG 0030H MAIN: MOV TMOD.

Copyleft 9 . A SJMP $ END 01/09/15 8051 Interrupts . #0FDH MOV SCON.#90H SETB TR1 MOV A. #50H MOV IE.Programming Serial Communication Interrupt Program to send 'A' ORG 0000H LJMP START ORG 0023H CLR TI RETI ORG 100H START:MOV TMOD. #20H MOV TH1. #'A' MOV SBUF.

1 Are High By Default ● Minimum Low for 4 Machine Cycles ● Edge Triggered – High to Low Pulse Minimum High for 1 Machine Cycle ● ● Minimum Low for 1 Machine Cycle ● TCON Register controls the type of interrupt 01/09/15 8051 Interrupts .Copyleft 10 .External Hardware Interrupts ● INT0 – P3.2 ● INT1 – P3.3 ● Level Triggered – Low-Level Signal triggers Interrupt ●INT0.

TCON Register 01/09/15 8051 Interrupts .Copyleft 11 .

1 for INT1 ORG 0000H LJMP MAIN ORG 0003H CPL P1.0 RETI ORG 0013H CPL P1.#85H SJMP $ END 01/09/15 8051 Interrupts .1 RETI MAIN: MOV IE.0 when Interrupt INT0 occurs and P1.Copyleft 12 .Example – External Interrupts ● Toggle P1.

Copyleft 13 .Interrupt Priority in 8051 01/09/15 8051 Interrupts .

Copyleft 14 .IP(Interrupt Priority) Register 01/09/15 8051 Interrupts .

1 at INT0 and OFF at INT1 Interrupt 01/09/15 8051 Interrupts .1 With a delay of 60ms using Interrupts ● Switch ON LED at P1.Copyleft 15 .Problems for LTC – Using Interrupts ● Receive 10 Characters Serially and Store the data in consecutive RAM Locations from 50H Using Interrupts ● Serially Receive Data Continuously and Transmit Back the same using Interrupts ● Program to toggle P1.

Pearson Education 01/09/15 8051 Interrupts . CENGAGE Learning ● Microcontrollers[Theory and Applications].Copyleft 16 .sites. Tata McGraw Hill ● The 8051 Microcontroller and Embedded Systems. 3rd Edition.google. Ayala. Ajay V Deshmukh.com/site/sripathroykoganti/my-forms ● The 8051 Microcontroller. Muhammad Ali Mazidi.References ● https://www.

Copyleft 17 . Thank You 01/09/15 8051 Interrupts .