Discussion in "8051 Discussion Forum" started by    HiteshDR    Dec 24, 2007.
Mon Dec 24 2007, 01:54 pm
#1
STEPPER EQU P1
KEY EQU P2
KEY_1 EQU P2.0
KEY_2 EQU P2.1
KEY_3 EQU P2.2
KEY_4 EQU P2.3

Org 0h
Ljmp Main

Org 0200h
Main: Mov A, #00h
Mov Stepper, A
Mov Key, A
Setb Key_1
Mov A, Key
Jnz Ant_clk

clk_wise:mov Stepper, #0ch
Acall Delay_1ms
Mov Stepper, #06h
Acall Delay_1ms
Mov Stepper, #03h
Acall Delay_1ms
Mov Stepper, #09h
Acall Delay_1ms
Sjmp Main

Ant_clk:mov Stepper, #09h
Acall Delay_1ms
Mov Stepper, #03h
Acall Delay_1ms
Mov Stepper, #06h
Acall Delay_1ms
Mov Stepper, #0ch
Acall Delay_1ms
Ret

DELAY_1MS: MOV R6, #231D ; 1 MILLISECONDS DELAY
GOTO: NOP
NOP
DJNZ R6, GOTO
RET


i have problem in this code.
the ant_clk loop runs only once
on next time program enters to the ant_clk loop but its not completing the loop. the program is returing to the line one of the program after desplaying 09 on port1.

what should be the reason for not completeing the loop?
wher should be the mistak??


[ Edited Mon Dec 24 2007, 02:34 pm ]
Mon Dec 24 2007, 02:39 pm
#2
the reason is..
in your main routine.. you are using..
Jnz Ant_clk

that means you are jumping to Ant_clk..
but at the end of Ant_clk routine.. you are using "Ret" you should use jump there.. you cannot return without calling a subroutine.
Mon Dec 24 2007, 02:42 pm
#3
you mean to say i have to write

sjmp main


instaed of

ret



am i right...???
Mon Dec 24 2007, 02:44 pm
#4
try using

Sjmp clk_wise


insteadt of
Ret


in the Ant_clk routine..
 HiteshDR like this.
Mon Dec 24 2007, 02:46 pm
#5
well it depends on you how you are coding and what you are trying to do..i just gave you the reason why its not coming out from Ant_clk routine
i recommend you to rewrite your main routine....
 HiteshDR like this.

Get Social

Information

Powered by e107 Forum System

Downloads

Comments

Richardgar
Sat Apr 20 2024, 11:05 am
AntoniaRoons
Fri Apr 19 2024, 09:59 pm
carpinteyrowrl
Fri Apr 19 2024, 02:51 pm
DonaldJAX
Fri Apr 19 2024, 01:08 pm
Lewisuhakeply
Thu Apr 18 2024, 06:00 pm
Darrellciz
Thu Apr 18 2024, 11:07 am
Charlessber
Thu Apr 18 2024, 09:29 am
BartonSem
Thu Apr 18 2024, 04:56 am