0% found this document useful (0 votes)
182 views3 pages

An Example of Interrupt Programming

The document describes an example of interrupt programming using an 89S52 microcontroller. The microcontroller counts from 0 to 100 on port 0 and triggers an interrupt when pin 13 goes low, reading the value from port 1 and displaying it on port 0 before continuing the counting routine. The circuit and assembly code for implementing this are provided.

Uploaded by

ThuNguyenvan
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
182 views3 pages

An Example of Interrupt Programming

The document describes an example of interrupt programming using an 89S52 microcontroller. The microcontroller counts from 0 to 100 on port 0 and triggers an interrupt when pin 13 goes low, reading the value from port 1 and displaying it on port 0 before continuing the counting routine. The circuit and assembly code for implementing this are provided.

Uploaded by

ThuNguyenvan
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 3

An Example of Interrupt Programming

Description:
In this example, I programmed the 89S52 to work with INT1 interrupt.
It move to port 0 numbers from 0 to 100 respectively and repeatedly
If Pin 13( INT1) is set to 0, it do the interrupt: Read from Port1 and move to
Port0
But as INT1 is back to High, it returns to counting routine, countinue from
the value before interrupt

This is the circuit for the example:

U1
19 39
XTAL1 P0.0/AD0
38
P0.1/AD1
37
P0.2/AD2
18 36
XTAL2 P0.3/AD3
35
P0.4/AD4
34
P0.5/AD5
33
P0.6/AD6
9 32
RST P0.7/AD7

R3 P2.0/A8
21
U2
1R R2 P2.1/A9
22
1R 23 7 13
P2.2/A10 A QA
29 24 1 12
PSEN P2.3/A11 B QB
30 25 2 11
ALE P2.4/A12 C QC
31 26 6 10
EA P2.5/A13 D QD
27 4 9
P2.6/A14 BI/RBO QE
28 5 15
P2.7/A15 RBI QF
3 14
LT QG
1
P1.0/T2 P3.0/RXD
10 R1
2 11 1R 74LS47
P1.1/T2EX P3.1/TXD
3 12
P1.2 P3.2/INT0
4 13
P1.3 P3.3/INT1
5 14
P1.4 P3.4/T0
6 15
P1.5 P3.5/T1
7 16
P1.6 P3.6/WR
8 17
P1.7 P3.7/RD
AT89C52

Circuit for 89S52 working with INT1 Interrupt

This is the code in ASM

; This program is written for 89S52 to do these works:


; It Drive a 74LS47 to count from 0 to 9 repeatedly, 7447 is connected
to 4 low significant pins of Port 0
; But when Pin INT1 is set, It Pause counting and read from Port 1
then display the value to port 0
; Use interrupt

ORG 000H
LJMP Main ; Jump to Main

ORG 0013H ; Interrupt


Push P0 ; Push value of P0 to stack
Mov A, P1
Mov P0, A
Mov R3, #200
Back: Djnz R3,Back ; Wait

Pop P0 ; Get P0 from the stack


RETI ; Return from interrupt

;-----------Main------------
ORG 30H
Main:
Mov IE, #10000100B ; INT1 interrupt enable

Start:
Mov P0, #0 ; all the out put at Pin 0s are
low
LCall Delay ; Call function for 1s delay
Mov P0, #1 ; Output is 1
LCall Delay
Mov P0, #2 ; Output is 2
LCall Delay
Mov P0, #3 ; Output is 3
LCall Delay
Mov P0, #4 ; Output is 4
LCall Delay
Mov P0, #5 ; Output is 5
LCall Delay
Mov P0, #6 ; Output is 6
Lcall Delay
Mov P0, #7 ; Output is 7
LCall Delay
Mov P0, #8 ; Output is 8
LCall Delay
Mov P0, #9 ; Output is 9
LCall Delay

Sjmp Start ; Back to start

; Function Delay

Delay:
Mov R7,#0FFH ;R7= FF
Loop2: Mov R6,#0FFH ;R6= FF
Loop1: Djnz R6,Loop1 ;Decrease R6 for R6 greater
than zero then jump to Loop1
Djnz R7,Loop2 ;Decrease R7 for R7 greater
than zero then jump to Loop2
Ret ;End the function
Delay and return memory
End ;End program

This circuit and code work well in my

You might also like