Anyone knows if uVision can register the maximum stack usage in
debug mode?.. Is very useful to run the code in the target and then
check the maximum usage of the stack in any moment in order to be
safe about the size. Perhaps anyone knows a better way to calculate
You have to distinguish two radically different things here: you can either measure, or calculate.
Measuring is done either by the "check how much of my 0xDEADBEEF is left untouched" method, or by using real-time debuggers that can track the stack pointer(s) during execution. The reliability of the result is, at best, questionable, because you never really know if the test run hit the worst-case situation for stack usage, even remotely.
Calculating, if even possible, is done at compile and link time, and relies on the compiler's knowledge of two things: maximum stack usage of each compiled function, and the structure of which functions are called by which other ones (i.e.: the call tree). This method is extremely reliable, but has severe limits of applicability, because many common code patterns make it excessively hard, if not right-out impossible, to build a correct call tree.
View all questions in Keil forum