Discussion in "Project Addition or Changes" started by    koushal    Apr 21, 2007.
Wed Aug 15 2007, 05:28 pm
#21
yeah send it to my mail... or zip the code, the size will get reduce.. either way you can do it.
Thu Aug 16 2007, 07:17 am
#22
Rickey,

I have sent the code to you. Please check your email.

Thanks,
SGH
Thu Aug 16 2007, 12:07 pm
#23
I checked your code.. well is big.. so and not so easy to understand at once.. what i can suggest you is.. change your stack pointer to somewhere around 60H and see if the hanging problem is happening again or not.. I am sure that will solve your purpose..

And if everything works... i can add your project to my 8051 Project section. Also give me a screenshot of working clock
Thu Aug 16 2007, 12:28 pm
#24
Rickey,

Thanks for checking the code. Yes, it is very big.

I'll change the stack pointer address and try again. Probably will not get the result instantly as the hanging problem occur randomly. Will let you know the results.

In your previous post, you mentioned about 'complete stack'. Would you please elaborate briefly what is a complete stack and how to identify it ?.


Many thanks,
SGH
Thu Aug 16 2007, 04:07 pm
#25
ok i explain the problem of hanging.. its like this..

lets say you have stack pointer at 0x70 as in your case..

so you call a function, 2 bytes are used.. also when interrupt occur, the contents has to be saved and then jump.. this way you are using the stack..
Lets say.. you have 5 calls in a routine.. like from your main you have calls.. you call one routine then in again you call another one from the called routine and so on..
so your stack will be filled with 5 addresses and your 10 bytes will be used. the next address for the stack is 0x80, which is not writable for the stack (because its P0 address). So when u again make a call.. you will be successfully able to go to that function, but CPU will not be able to write to the stack the address from where call came, so when you execute the RET instruction, you end up somewhere else.. and hence system HANGS!

This occurs occasionally but surely it happens because... might be just one somewhere you are making more than 5 calls.. or using stack somehow. So that is what i meant with using complete stack.. from 0x70 to 0x7F.

To remove this.. i just told you to move your stack pointer to 0x60, so you have 20 byte of stack. The chances of false jumping will get reduced and hence no HANGS!

I hope i am clear! if any other question you may please ask.
 SGH like this.
Mon Aug 20 2007, 07:26 am
#26
Thanks Rickey for the info. I'm trying the revised code.

SGH
Thu Aug 23 2007, 02:19 pm
#27
I'm using following code to turn on/off lamps. Occasionally, the system hang after finished executing the switch_lamp routine.

Is it because the way I used the timer or there were other area I overlooked ?.

Thanks,
SGH
Thu Aug 23 2007, 02:23 pm
#28
I didn't see the attachment. Here is the code.

count20_a data 30h
count20_b data 31h
count20_c data 32h
count20_d data 33h
second_a data 34h
second_b data 35h
second_c data 36h
second_d data 37h

switch_lamp: mov p2,#11100100b
lcall delay_t1

cycle_2: mov p2,#01100100b
lcall delay_t2

cycle_3: mov p2,#11100100b
lcall delay_t3

cycle_4: mov p2,#00010000b
lcall delay_t4

mov p2,#00000000b
ret
;==============================================================
delay_t1: mov tmod,#01h
mov count20_a,#20
mov second_a,#00
again_a: mov th0,#76
mov tl0,#01
setb tr0
wait_a: jnb tf0,wait_a
clr tf0
clr tr0
djnz count20_a,again_a
mov count20_a,#20
inc second_a
mov a,second_a
cjne a,#5,again_a
ret
;==============================================================
delay_t2: mov tmod,#01h
mov count20_b,#20
mov second_b,#00
again_b: mov th0,#76
mov tl0,#01
setb tr0
wait_b: jnb tf0,wait_b
clr tf0
clr tr0
djnz count20_b,again_b
mov count20_b,#20
inc second_b
mov a,second_b
cjne a,#6,again_b
ret
;==============================================================
delay_t3: mov tmod,#01h
mov count20_c,#20
mov second_c,#00
again_c: mov th0,#76
mov tl0,#01
setb tr0
wait_c: jnb tf0,wait_c
clr tf0
clr tr0
djnz count20_c,again_c
mov count20_c,#20
inc second_c
mov a,second_c
cjne a,#7,again_c
ret
;==============================================================
delay_t4: mov tmod,#01h
mov count20_d,#20
mov second_d,#00
again_d: mov th0,#76
mov tl0,#01
setb tr0
wait_d: jnb tf0,wait_d
clr tf0
clr tr0
djnz count20_d,again_d
mov count20_d,#20
inc second_d
mov a,second_d
cjne a,#8,again_d
ret
;==============================================================SSorry for the long post.

Thanks,
SGH

Thu Aug 23 2007, 02:32 pm
#29
usually hanging in the code is coz of the problem i explained. But i am really not sure its happening in your case..
but still try changing the stack again.. looking at the code wont help.. coz its logical error.. not coding error..

Get Social

Information

Powered by e107 Forum System

Downloads

Comments

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
DonaldKnown
Thu Apr 18 2024, 12:24 am
utaletxcyw
Wed Apr 17 2024, 10:21 am