CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

functions return to different location.

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Apr 23, 2006 10:53 am     Reply with quote

Do you have one function that is very large ? If so, try to break it up
into two functions. This will allow the compiler to find a location in ROM
for the functions. It's easier for the compiler if you have smaller
functions. Example:

Code:
main()
{

func();  // One very large function

while(1);
}


Code:
main()
{

// Two smaller functions
func_A();
func_B();

while(1);
}
Ahmed



Joined: 07 Mar 2006
Posts: 19

View user's profile Send private message

PostPosted: Tue Apr 25, 2006 1:46 pm     Reply with quote

Quote:
if you use the #separate directive anywhere in your
program, the compiler will not check the stack usage anymore.
You have to check it yourself by looking at the .LST file every time
the program is compiled


ok, my .LST file was as follow showing 7 locations only:

Quote:
ROM used: 5790 (71%)
Largest free fragment is 2048
RAM used: 69 (39%) at main() level
171 (98%) worst case
Stack: 7 locations


Is this mean that the initial problem (function returns..) isn't related to the stack or still this calculated stack location were not accuratedue to the #seprate files.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Apr 25, 2006 1:55 pm     Reply with quote

If there are only 7 stack levels listed, then there should be no problem
with stack overflow.


Do you still have the problem with functions returning to incorrect
addresses ? If so, here are some possible reasons:

1. Did you enable global interrupts while inside an interrupt routine ?

2. Are you using #ASM code, and jumping to some location in your
program ?

3. Are you using any special functions, such as goto_address() ?


Other possible reasons:

1. If you accidently write to RAM locations past the end of an array,
you could destroy the value of some variables (such as loop counters)
and your program would have erratic operation.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group