View previous topic :: View next topic |
Author |
Message |
rhaguiuda
Joined: 05 Sep 2007 Posts: 46 Location: Londrina - Brazil
|
Stack Overflow? |
Posted: Wed Jan 14, 2009 6:54 am |
|
|
My .sta file have this line:
Stack used: 11 worst case (out of 8 total available)
I'm using a PIC16F876 in my project.
Assuming that my PIC have 8 level stack, it means that I'll have stack overflow?
If so, how can I prevent such a thing? What is the "worst case" for the compiler?
Thanks _________________ Give a man a fish and you'll feed him for a day. Teach a man to fish, and you'll feed him for a lifetime. |
|
![](templates/subSilver/images/spacer.gif) |
RLScott
Joined: 10 Jul 2007 Posts: 465
|
Re: Stack Overflow? |
Posted: Wed Jan 14, 2009 7:25 am |
|
|
rhaguiuda wrote: | My .sta file have this line:
Stack used: 11 worst case (out of 8 total available)
I'm using a PIC16F876 in my project.
Assuming that my PIC have 8 level stack, it means that I'll have stack overflow?
If so, how can I prevent such a thing? What is the "worst case" for the compiler?
Thanks |
Yes, it means that you will have a stack overflow if your code visits every branch on the call tree. There are two things that use up stack: function calls and interrupts. Look at the file whose extention is ".TRE" in your workspace to see the call tree. You can open it in Notepad or any text editor, or even in the IDE. Then reorganize your program to reduce the number of nested function calls. Exactly how you do this will depend too much on your particular application to give any concrete advice. But at least the call tree wil show you where the problem is. _________________ Robert Scott
Real-Time Specialties
Embedded Systems Consulting |
|
![](templates/subSilver/images/spacer.gif) |
rhaguiuda
Joined: 05 Sep 2007 Posts: 46 Location: Londrina - Brazil
|
|
Posted: Wed Jan 14, 2009 7:31 am |
|
|
Thanks Robert! _________________ Give a man a fish and you'll feed him for a day. Teach a man to fish, and you'll feed him for a lifetime. |
|
![](templates/subSilver/images/spacer.gif) |
|