Created
October 10, 2016 00:04
-
-
Save Marzogh/09e141428964e2ed31bbcaf3bb358111 to your computer and use it in GitHub Desktop.
Gets and outputs a number of details about the state of the RAM on an Arduino Due
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Code courtesy of RayLivingston from the Arduino forums (http://forum.arduino.cc/index.php?topic=404908.msg2787555#msg2787555) */ | |
void ShowMemory(void) | |
{ | |
struct mallinfo mi=mallinfo(); | |
char *heapend=sbrk(0); | |
register char * stack_ptr asm("sp"); | |
pConsole->printf(" arena=%d\n",mi.arena); | |
pConsole->printf(" ordblks=%d\n",mi.ordblks); | |
pConsole->printf(" uordblks=%d\n",mi.uordblks); | |
pConsole->printf(" fordblks=%d\n",mi.fordblks); | |
pConsole->printf(" keepcost=%d\n",mi.keepcost); | |
pConsole->printf("RAM Start %lx\n", (unsigned long)ramstart); | |
pConsole->printf("Data/Bss end %lx\n", (unsigned long)&_end); | |
pConsole->printf("Heap End %lx\n", (unsigned long)heapend); | |
pConsole->printf("Stack Ptr %lx\n",(unsigned long)stack_ptr); | |
pConsole->printf("RAM End %lx\n", (unsigned long)ramend); | |
pConsole->printf("Heap RAM Used: %d\n",mi.uordblks); | |
pConsole->printf("Program RAM Used %d\n",&_end - ramstart); | |
pConsole->printf("Stack RAM Used %d\n",ramend - stack_ptr); | |
pConsole->printf("Estimated Free RAM: %d\n\n",stack_ptr - heapend + mi.fordblks); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment