Hi
There are several scenarios, which depends also on the operating system used (if it is using stacks for each thread it will be necessary to also monitor RAM use of each thread. Possibly different stacks for user and supervisor modes too).
Assuming a more simple system there are three main types of memory:
- variables (fixed size which can be seen in the map file)
- heap (if used - possibly the malloc support includes some routines to monitor free space. Often fixed size set up in the linker).
- Stack (used by routines and interrupts).
The third can be monitored (to get an idea of the stack depth used) by filling all RAM with a pattern on start up. By then monitoring the amount of RAM which has not had its patttern destroyed it is possible to know the 'safety margin' between the lowest stack mark since the system started and the highest variable location.
The uTasker project supports these with function calls:
- fnHeapAvailable();
- fnHeapFree();
- fnStackFree();
The results of these can be seen at the following on-line demo:
demo.uTasker.com on the admin web page.
Regards
Mark
www.uTasker.com