Skip to content

Instantly share code, notes, and snippets.

@jessicacarneiro
Created January 10, 2018 02:32
Show Gist options
  • Select an option

  • Save jessicacarneiro/3c4ee49513fcfd34ca0c4ae828662c04 to your computer and use it in GitHub Desktop.

Select an option

Save jessicacarneiro/3c4ee49513fcfd34ca0c4ae828662c04 to your computer and use it in GitHub Desktop.
uint32_t freeRam() // for Teensy 3.0
{
uint32_t stackTop;
uint32_t heapTop;
// current position of the stack.
stackTop = (uint32_t) &stackTop;
// current position of heap.
void* hTop = malloc(1);
heapTop = (uint32_t) hTop;
free(hTop);
// the difference is the free, available ram.
return stackTop - heapTop;
}
void setup()
{
}
void loop()
{
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment