|
|
View previous topic :: View next topic |
Author |
Message |
Tom-H-PIC
Joined: 08 Sep 2003 Posts: 105 Location: New Castle, DE
|
Stack overrun concerns! |
Posted: Wed Apr 07, 2010 6:17 am |
|
|
Hello All
I'm work on a project that started years back and has had a number of version of firmware released.
The compiler is 3.249, PIC16F916.
Would someone explain how the compiler handles the stack and what can be done to reduce it?
The 16F916 data sheet states that the 916 has an 8-level deep hardware stack.
The program that I have now works as it was designed.
But my concern is in look at the list file I see this.
" Stack: 7 worst case (6 in main + 1 for interrupts)"
Do I need to be concerned about this?
How do I reduce the stack load?
Tom |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19553
|
|
Posted: Wed Apr 07, 2010 7:19 am |
|
|
No problem.
The compiler calculates the 'worst case', by looking at where things are/can be called inside other things. So in your case, the 'worst case', is if an interrupt happens, when you are inside a subroutine, inside another, etc.. 6 deep in the 'main code', then another one for the interrupt. Nothing to worry about at all. Remember in the PIC, the stack is only used for call/return operations, not for data storage, so there is nothing 'extra' that can happen, and go beyond it's limits. Where it _would_ be a 'worry', would be if your code wanted 9 deep....
You can reduce stack usage, by making routines 'inline', but this then reduces the ability to split the code up, and fit it efficiently in the memory banks, and increases the risk of 'out of memory' errors. So long as you are inside the limits, don't worry.
Best Wishes |
|
|
Tom-H-PIC
Joined: 08 Sep 2003 Posts: 105 Location: New Castle, DE
|
Stack overrun concerns! |
Posted: Wed Apr 07, 2010 1:09 pm |
|
|
Thanks Ttelmah
That is what I thought and had been working under for years.
Then I got to thinking about it and did not have any references to back that up.
And this morning was not able find anything on the web after about an hour.
So thanks for your knowledge. Tom |
|
|
|
|
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
|