AnsweredAssumed Answered

How should I set my "heap" and "stack" size

Question asked by vu.andy on Nov 3, 2017
Latest reply on May 7, 2018 by JulienD

After compiling the codes, my code size is:

Program Size: Code=20140 RO-data=316 RW-data=540 ZI-data=2412 

Based on this information, how should I set my "heap" and "stack" size? 


My first question is the "heap" and "stack" size is for Per Function call?  Or is it for the entire program?


For example, if all my global variables are added up to, for example, 700 bytes total, then do I need to

set my "heap" size to be at least 700 bytes?  What would happen if I set heap size less than 700 bytes?

Of course each function call will have its own variables, and each function will call other functions so the stack size may not be known in advance.  Will the uProcessor crash if the allocated "stack" size in the .S file is less than needed during runtime?


So I guess my question is how would you determine heap and stack size?