Hello BasePointer,
While not directly related to detecting the required stack size, it has occurred to me that a few stack locations are being unnecessarily consumed when the main() function is called. Since this function never exits, there is no need for a return address, nor for CPU register values to be pushed onto the stack, as this memory will never be released. I suspect this RAM usage can be eliminated using suitable pragmas. While saving only a few bytes of RAM, this could be critical to low end applications, perhaps with as little as 128 bytes of RAM available.
Another consideration for minimising stack size is not to declare any local variables within main() - these again represent stack allocations that will never be released. Any variables directly required by main() should be global. However, this will not reduce total memory usage.
To further minimize stack usage, limit the number of variables passed to each function - don't use int values where a char values will suffice. If a large number of different parameters are required by a function, consider use of a global structure (not static), eliminating any recursive calls.
Otherwise, I would agree with others that the stack should be utilised as much as possible for local variables, as this will give more efficient RAM utilisation.
Regards,
Mac