Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
01/31/00 15:39
Read: times


 
#1357 - RE: about the stack
I can only agree with Vasilis, however, you could try resetting the stack pointer (mov sp, #3ch) at the start of every iteration of the main program loop. This will ensure that the stack starts afresh every loop iteration. If this makes it work, then you need a serious code review to see where your missing ret is. Note that if this doesn't make it work, then you may still have a stack problem.

Also, at the beginning of each loop compare the stack pointer to what it should be. At the beginning of the loop you should have unwound the stack pointer back to 3ch. If it is not, then toggle a port pin, to flash a led, or look at the line on a DSO.

I'm not sure whether this is true or not, because I mainly use 51's and not 52's, but to access the top half of ram you have to use indirect addressing. If your stack ends up higher than 7f, you will a)write over the SFR's and b) when the ret instruction reads the return address you have no idea what it will return. (Somebody let me know if that is true, please)

The other thing that I would do is work out the theoretical maximum stack depth by code review, and then on a timer interrupt look at the stack pointer. If it is too high, then flash a led as above.
Either way, you need a serious code review.

Best of luck.



List of 6 messages in thread
TopicAuthorDate
about the stack            01/01/70 00:00      
RE: about the stack            01/01/70 00:00      
RE: about the stack            01/01/70 00:00      
RE: about the stack            01/01/70 00:00      
RE: about the stack            01/01/70 00:00      
RE: about the stack            01/01/70 00:00      

Back to Subject List