|
|
What is a good value for the HW/return stack size? |
| The HW/return stack is primarily used for return addresses for function calls. Size needed for this can be approximated by (size of address on processor) * (depth of deepest call tree).
Many processor have 2-byte addressing, so 2*(size of deepest call tree)would be reasonable. If the address size is larger, the HW/return stack will have to be larger as well. {ATmega640, ATmega1280, ATmega1281, ATmega2560, ATmega2561} have three-byte Program Counter which means the HW/return stack should be at least 3 * (depth of deepest call tree) Unfortunately (depth of deepest call tree) needs to be computed individually for each program. A reasonable approximation (for processors with 2-byte addressing) is a value of between [16,20] for programs that do not use floating point and a value between [30, 40] for programs that do use floating point. The HW/return stack is primarily used to hold the return addresses from function calls. There are some cases where the runtime library routines will use it to temporarily save and restore values. Note that having a too large HW/return stack value will decrease the amount of RAM available to the Software Stack and can cause problems. | |
| [Append to This Answer] |
| Previous: |
|
| Next: |
|
| ||||||||