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

Stack Overflow?

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



Joined: 05 Sep 2007
Posts: 46
Location: Londrina - Brazil

View user's profile Send private message

Stack Overflow?
PostPosted: Wed Jan 14, 2009 6:54 am     Reply with quote

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.
RLScott



Joined: 10 Jul 2007
Posts: 465

View user's profile Send private message

Re: Stack Overflow?
PostPosted: Wed Jan 14, 2009 7:25 am     Reply with quote

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
rhaguiuda



Joined: 05 Sep 2007
Posts: 46
Location: Londrina - Brazil

View user's profile Send private message

PostPosted: Wed Jan 14, 2009 7:31 am     Reply with quote

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.
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