Discussion in "General help Guidance and Discussion" started by    abbas1707    Aug 8, 2007.
Sat Sep 15 2007, 03:45 am
#31
hi ajay!
here is my first program in assembly:) for this project
i just now tested it on proteus but it gets stuck after 30 seconds on proteus.i have not tested it at board yet.
since im a newbie to assembly so plz can u have a look at it if u have time!!!
circuit is same as i posted before

Sat Sep 15 2007, 01:08 pm
#32
well of course it will get stuck. the reason is.. you are calling the subroutines and you are not using the instruction "RET".
so at the end of every subroutine you must put the instruction RET.
I am attaching the code.. check it carefully
Sat Sep 15 2007, 01:09 pm
#33
i donno not able to attach file.. so just copying and pasting it here..

org 0
ljmp main

org 0bh
cpl clock
reti

org 23h
ljmp serial

org 30h
main:
	clock bit P3.2
	sc bit P3.3
	eoc bit P3.4
	oe bit P3.5
	ale bit P3.7

	mov dptr,#aray
	mov TMOD,#22h
	mov TH1,#0FDh
	mov SCON,#50h
	mov TH0,#0a3h
	mov IE,#10010010B
	setb TR1
	setb TR0
	mov P2,#0ffh
	setb eoc
	clr ale
	clr oe
	clr sc
while1:
	clr P1.0
	clr P1.1
	clr P1.2
	acall msdelay
	setb ale
	acall msdelay
	setb sc
	acall msdelay
	clr ale
	clr sc
wait:
	jb eoc,wait
wait1:
	jnb eoc,wait1
	setb oe
	acall msdelay
	mov r2,P2
	clr oe
	acall convert
	sjmp while1

convert:
	mov a,r2
	mov b,#10
	div ab
	mov r7,b;lower
	mov b,#10
	div ab
	mov r6,b ;mid
	mov r5,a ;high
	acall sendString
	ret

sendString:
	mov a,r5
	movc a,@a+dptr
	mov SBUF,a
fis:
	JNB TI,fis
	acall msdelay
	mov a,r6
	movc a,@a+dptr
	mov SBUF,a
sec:
	JNB TI,sec
	acall msdelay
	mov a,r7
	movc a,@a+dptr
	mov SBUF,a
thd:
	JNB TI,thd
	acall msdelay
	mov SBUF,#","
com:
	JNB TI,com
	acall msdelay
	ret

msdelay:
	mov r2,#50
he:
	mov r3,#250
she:
	nop
	nop
	djnz r3,she
	djnz r2,he
	ret

aray: db "0123456789"

serial:
	JB TI,trans
	reti
trans:
	clr TI
	reti
	end

 abbas1707 like this.
Sat Sep 15 2007, 02:48 pm
#34
yeah now it works
u put ret at end of subroutine sendString.but y it was not working wid ljmp while1?????
plz clarify becoz i have only 1 day knowledge of assembly so i cant understand this
Sat Sep 15 2007, 03:27 pm
#35
you know why your controller stops working after 30sec?
because of stack overflow..
you are using acall.. that means call to a subroutine.. and in the subroutine you are not returning.. so.. when you do this all in loop.. the stack stores the address from where call is made.. and when stack overflow.. on next call the address will not be stored anywhere.. and when executing routine like msdelay and when it reach to RET instruction it will jump to some unknown location because the actual address couldn't be stored coz of stack overflow.

Now.. if you want to use ur program.. with LJMP while1
then.. remove the calls to sendstring and convert in your program.. because they all comes in order.. no address will be stored in stack. except for routines with RET statement.
Sat Sep 15 2007, 06:39 pm
#36
now some different problem
program tested on microcontroller board instead of proteus this time.
but...
i get reading to hyper terminal only if i press reset button on board.
i.e press reset get one reading then press reset and get other reading.......... :mad :mad :mad
however my frend program working on board
no problem in harware no problem in software(as it was fine on proteus)
i m just going mad :mad
Sat Sep 15 2007, 06:41 pm
#37
i think i shud quit programming now and work wid my frends program :mad :-s
i hav done every effort i can


[ Edited Sat Sep 15 2007, 06:42 pm ]
Sat Sep 15 2007, 07:32 pm
#38
there must be something you are missing.. well.. i donno what to say.. don't loose hope
Sun Sep 16 2007, 05:15 pm
#39
hi
anyone knows how to generate crystal reports and how to attach them with vb??



Sun Sep 16 2007, 05:59 pm
#40
abbas it looks interesting :-)

Get Social

Information

Powered by e107 Forum System

Downloads

Comments

Michailqfh
Fri Mar 29 2024, 01:53 am
Bobbyerilar
Thu Mar 28 2024, 08:08 am
pb58
Thu Mar 28 2024, 05:54 am
Clarazkafup
Thu Mar 28 2024, 02:24 am
Walterkic
Thu Mar 28 2024, 01:19 am
Davidusawn
Wed Mar 27 2024, 08:30 pm
Richardsop
Tue Mar 26 2024, 10:33 pm
Stevencog
Tue Mar 26 2024, 04:26 pm