0% found this document useful (0 votes)
5 views

Microcontrollers - 8051 Interrupts and interrupt programing

Uploaded by

Priyanshu prasad
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

Microcontrollers - 8051 Interrupts and interrupt programing

Uploaded by

Priyanshu prasad
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 43

8051 Interrupts and interrupt programing

External
hardware
interrupts
External input for
counter 0 and
counter 1
(High byte timer 0)

(Enable timer 0)
(Jump if Timer 0 overflow flag bit is not set)
processor vectors to execute interrupt service routine located at
program address 000Bh
(Disable timer 0)

(Clear Timer 0 overflow flag bit)


(MSB) TMOD Register (LSB)
GATE C/T M1 M0 GATE C/T M1 M0
Timer 1 Timer 0
Both Timer 0 &Timer 1 use the same Mode register TMOD.
It is an-8-bit register .The lower 4-bits are meant for Timer 0 &the upper
4-bits are meant for Timer 1
It is not bit addressable.
It is used similar to any other register of 8051 . For ex:
MOV TMOD,#21H
Bit TMOD Bit Function
7 Gate -- OR gate enable bit which controls RUN/STOP of timer 1. Set to 1 by program to
enable timer to run if bit TR1 in TCON is set and signal on external interrupt INT1 is high.
Cleared to 0 by program to enable time to run if bit TR1 is set.
6 C/T -- Set to 1 by program to make timer 1 act as a counter by counting pulses from
external input pins 3.5. Cleared to zero by program to make timer act as a timer by
counting internal frequency.
5 M1 -- Timer/counter operating mode select bit 1. Set/cleared by program to select mode.
4 M0 -- Timer/counter operating mode select bit 0. Set/cleared by program to select mode.
3 Gate -- OR gate enable bit which controls RUN/STOP of timer 0. Set to 1 by program to
enable timer to run if bit TR0 in TCON is set and signal on external interrupt INT0 is high.
Cleared to 0 by program to enable time to run if bit TR0 is set.
2 C/T -- Set to 1 by program to make timer 0 act as a counter by counting pulses from
external input pin 3.4. Cleared to zero by program to make timer act as a timer by counting
internal frequency.
1 M1 -- Timer/counter operating mode select bit 1. Set/cleared by program to select mode.
0 M0 -- Timer/counter operating mode select bit 0. Set/cleared by program to select mode.
TCON Register
External External
Timer 1 Timer 0
interrupt 1 interrupt 0
overflow flag overflow
edge flag edge flag
flag

TF1 TR1 TF0 TR0 IE1 IT1 IE0 IT0

External External
Timer 1 Run interrupt 1
Timer 0 Run interrupt 0
control bit edge type
control bit edge type
control control
Bit Symbol TCON Bit Function
7 TF1 Timer 1 Overflow flag. Set when timer rolls from all 1's to 0. Cleared when processor vectors to execute
interrupt service routine located at program address 001Bh.

6 TR1 Timer 1 run control bit. Set to 1 by program to enable timer to count; cleared to 0 by program to halt timer.

5 TF0 Timer 0 Overflow flag. Set when timer rolls from all 1's to 0. Cleared when processor vectors to execute
interrupt service routine located at program address 000Bh.

4 TR0 Timer 0 run control bit. Set to 1 by program to enable timer to count; cleared to 0 by program to halt timer.

3 IE1 External interrupt 1 Edge flag. Set to 1 when a high-to-low edge signal is received on port 3.3 (INT1). Cleared
when processor vectors to interrupt service routine at program address 0013h. Not related to timer operations.

2 IT1 External interrupt 1 signal type control bit. Set to 1 by program to enable external interrupt 1 to be triggered
by a falling edge signal. Set to 0 by program to enable a low-level signal on external interrupt 1 to generate an
interrupt.

1 IE0 External interrupt 0 Edge flag. Set to 1 when a high-to-low edge signal is received on port 3.2 (INT0). Cleared
when processor vectors to interrupt service routine at program address 0003h. Not related to timer operations.

0 IT0 External interrupt 0 signal type control bit. Set to 1 by program to enable external interrupt 1 to be triggered
by a falling edge signal. Set to 0 by program to enable a low-level signal on external interrupt 0 to generate an
interrupt.

You might also like