2021-02-25 12:53 AM
Hi,
I want to know how much SRAM I am using at any one time during debugging. I can calculate the approximate total SRAM used as the majority of my variables are global so I can just sum the total bytes used up by my global variables and have a rough idea. I would like to know if there is a way that one can determine the exact SRAM usage at any time?
2021-02-25 01:21 AM
In plain C: global variables + heap space + stack space. You can get the top of heap by a call to sbrk(0) (or inspecting the variableassociated with it) and the stack by reading the stack pointer. Compare both to the .map / .ld files.
If you have an RTOS... each task has its own stack and maybe tread local storage. Things are more complicated. When in doubt check the source code.
hth
KnarfB
2021-02-25 01:24 AM
Thanks, I've never heard of sbrk before i'll check it out. I assume that there's not something in the IDE then that can provide the diagnostics?