At 13:05 29-8-2011, JMGross wrote: >----- Ursprüngliche Nachricht ----- >Von: N. Coesel >Gesendet am: 26 Aug 2011 13:26:47 > > > I've been reading this thread for a while and it > > makes me wonder if there is some kind of tool > > which can analyze the code and determine the > > stack usage? I think this may be a safer route > > than to depend on a real-time stack check. The > > big question is: what do you do when the stack > > overflows? Just resetting the MCU is probably not > > an option so you'll have to add extra code to > > handle such an 'exception'. That does not seem very trivial to me. > >Stack usage is a dynamic thing and happens at real-time. >Unless you code a benchmarck that always executes >exactly the same way, there is no way to determine stack >usage.
If that where true, then you would not be able to make reliable embedded firmware. >Some minor, small projects might be analyzeable, but for the >majority, it's up to you to guess and hope :) That depends on how you organize your projects. I always divide my projects into -more or less- independant processes with an init function (called once) and a run function (called from main continuously). This means that every process can use almost the entire stack space for itself. Because the processes are usually relatively small it is possible to make a good estimation on stack usage. Divide and conquer! To check the stack in a running target I use the timer interrupt to determine the worst case stack usage. I do this by using some inline assembly to get the stack pointer and update the recorded stack pointer if the stack grew bigger. Even thought the timer interrupt method only samples the stack pointer this method works pretty good if you let the software run for a while. Nico Coesel o---------------------------------------------------------------o | N C T Developments | |Innovative embedded solutions | o---------------------------------------------------------------o ------------------------------------------------------------------------------ EMC VNX: the world's simplest storage, starting under $10K The only unified storage solution that offers unified management Up to 160% more powerful than alternatives and 25% more efficient. Guaranteed. http://p.sf.net/sfu/emc-vnx-dev2dev _______________________________________________ Mspgcc-users mailing list Mspgcc-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mspgcc-users