Arduino notes

From Noah.org
Revision as of 14:31, 30 July 2012 by Root (talk | contribs) (Created page with 'Category:Engineering == debug memory problems (out of RAM) == See [http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1213583720/20 Arduino Forum on memory usage]. This functi…')
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search


debug memory problems (out of RAM)

See Arduino Forum on memory usage. This function will return the amount of RAM free. This accounts for the stack and heap used.

int freeRam () {
  extern int __heap_start, *__brkval; 
  int stack_top; 
  return (int) &stack_top - (__brkval == 0 ? (int) &__heap_start : (int) __brkval); 
}

Serial.println(freeRam());