Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Simply question about the ASM (INT0), Please help~!

Status
Not open for further replies.

johnny01hk

Junior Member level 1
Joined
Apr 8, 2010
Messages
19
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,432
I want to add the INT0 into my program,
When the INT have Logic 0 input,then the progarm will auto jump to Z,
also stop before working process.
But I don't know how to add that function on my progarm.
And I don't know hot to setting the other point.
For example the IT0, EA, EX0,

Who can help me write a command and setting into my progarm?


--------------------------------------------


ORG 00H
JMP START

ORG 100h

START:
SETB P2.0 ;Motion detector Input
SETB P2.1 ;Metal detector Input
CLR P1.0
CLR P1.1

Loop:
JNB P2.0, X
JNB P2.1, Z
SJMP Loop

; = = = = = = = = = = = = = =

X:
SETB P1.0
CLR P1.1
LCALL Delay ;Call Delay
CLR P1.0
CLR P1.1
SJMP START

Z:
SETB P1.1
CLR P1.0
LCALL Delay ;Call Delay
CLR P1.0
CLR P1.1
SJMP START

; = = = = = = = = = = = = = =

Delay:
MOV R2, #50 ;~1s
S1:
MOV R3, #200
S2:
MOV R4, #200
DJNZ R4, $
DJNZ R3, S2
DJNZ R2, S1
RET

END
 

It may not be the final version but at least will give you an idea on how to use and acitvate Int0 ..

Code:
$NOPAGING
$MOD252
;BIT  PSW.1 is used as general purpose flag ..

ORG		0000H 
LJMP		START

ORG		0003h
LJMP		ExtInt0		; External interrupt 0 ..

ORG 0100h 

START:

SETB		TCON.0		; Int0 active at the edge..
SETB		IE.7			; General interrupt active..
SETB		IE.0			; Int0 is enabled..

START2:

SETB P2.0 ;Motion detector Input 
; Metal detector to be connected to /INT0 .. SETB P2.1 - Metal detector Input 
CLR P1.0 
CLR P1.1 

Loop: 
JNB P2.0, X 
;			JNB P2.1, Z 
JB	PSW.1, Z
SJMP Loop 

; = = = = = = = = = = = = = = 

X: 
SETB P1.0 
CLR P1.1 
LCALL Delay ;Call Delay 
CLR P1.0 
CLR P1.1 
SJMP START2 

Z:
CLR	PSW.1		; Clear flag .. 
SETB P1.1 
CLR P1.0 
LCALL Delay ;Call Delay 
CLR P1.0 
CLR P1.1
SJMP START2 

; = = = = = = = = = = = = = = 

Delay: 
MOV R2, #50 ;~1s 
S1: 
MOV R3, #200 
S2: 
MOV R4, #200
S3:
JB	PSW.1, Del_Exit	; If interrupt occured exit delay .. 
DJNZ R4, S3 
DJNZ R3, S2 
DJNZ R2, S1
Del_Exit: 
RET

; = = = = = = = = = = = = =
ExtInt0:
SETB		PSW.1		; set flag on interrupt ..
RETI 

END

IanP
:D
 

    johnny01hk

    Points: 2
    Helpful Answer Positive Rating
IanP said:
It may not be the final version but at least will give you an idea on how to use and acitvate Int0 ..

Code:
$NOPAGING
$MOD252
;BIT  PSW.1 is used as general purpose flag ..

ORG		0000H 
LJMP		START

ORG		0003h
LJMP		ExtInt0		; External interrupt 0 ..

ORG 0100h 

START:

SETB		TCON.0		; Int0 active at the edge..
SETB		IE.7			; General interrupt active..
SETB		IE.0			; Int0 is enabled..

START2:

SETB P2.0 ;Motion detector Input 
; Metal detector to be connected to /INT0 .. SETB P2.1 - Metal detector Input 
CLR P1.0 
CLR P1.1 

Loop: 
JNB P2.0, X 
;			JNB P2.1, Z 
JB	PSW.1, Z
SJMP Loop 

; = = = = = = = = = = = = = = 

X: 
SETB P1.0 
CLR P1.1 
LCALL Delay ;Call Delay 
CLR P1.0 
CLR P1.1 
SJMP START2 

Z:
CLR	PSW.1		; Clear flag .. 
SETB P1.1 
CLR P1.0 
LCALL Delay ;Call Delay 
CLR P1.0 
CLR P1.1
SJMP START2 

; = = = = = = = = = = = = = = 

Delay: 
MOV R2, #50 ;~1s 
S1: 
MOV R3, #200 
S2: 
MOV R4, #200
S3:
JB	PSW.1, Del_Exit	; If interrupt occured exit delay .. 
DJNZ R4, S3 
DJNZ R3, S2 
DJNZ R2, S1
Del_Exit: 
RET

; = = = = = = = = = = = = =
ExtInt0:
SETB		PSW.1		; set flag on interrupt ..
RETI 

END

IanP
:D

Thx so much~~!
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top