View previous topic :: View next topic |
Author |
Message |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sun Apr 23, 2006 10:53 am |
|
|
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
|
|
Posted: Tue Apr 25, 2006 1:46 pm |
|
|
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
|
|
Posted: Tue Apr 25, 2006 1:55 pm |
|
|
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. |
|
|
|