ark5230
Advanced Member level 3
![Advanced Member level 3](/styles/images/ranks/glevel3.gif)
I am using 89s52 to test use of External Interrupt..
1. The main program blinks two LED's
2. On one interrupt 1 LED blinks and other goes off.
3. On the other interrupt second LED blinks and first one goes off.
The two LED's are on P0.0 and P0.1
Interrupt inputs are given to pins P3.2 and P3.3 using a push button.
All works well but after the control returns from interrupt, it takes some 20 seconds to resume the main program.
I am not able to understand what is going wrong.
Any suggestions will be of great help.
The code is as follows.
1. The main program blinks two LED's
2. On one interrupt 1 LED blinks and other goes off.
3. On the other interrupt second LED blinks and first one goes off.
The two LED's are on P0.0 and P0.1
Interrupt inputs are given to pins P3.2 and P3.3 using a push button.
All works well but after the control returns from interrupt, it takes some 20 seconds to resume the main program.
I am not able to understand what is going wrong.
Any suggestions will be of great help.
The code is as follows.
Code:
ORG 0
SJMP MAIN
ORG 3
LJMP ISR1
ORG 0BH
RETI
ORG 13H
LJMP ISR2
ORG 1BH
RETI
ORG 23H
RETI
ORG 2BH
RETI
ORG 30H
MAIN: MOV P3,#255
SETB EA
SETB EX0
SETB EX1
MOV P0,#0
GEN: MOV R2,#10
MOV P3,#255
CALL DELAY
SETB P0.0
SETB P0.1
CALL DELAY
CLR P0.0
CLR P0.1
SJMP GEN
ISR1: MOV P0,#0
CALL DELAY
MOV P0,#0
SETB P0.0
CALL DELAY
CLR P0.0
DJNZ R2, ISR1
RETI
ISR2: MOV P0,#0
CALL DELAY
MOV P0,#0
SETB P0.1
CALL DELAY
CLR P0.1
DJNZ R2, ISR2
RETI
DELAY:
MOV R3,#5
LP3: MOV R4,#100
LP2: MOV R5,#255
LP1: DJNZ R5, LP1
DJNZ R4, LP2
DJNZ R3, LP3
RET
END
Last edited: