Watch and log free sram during runtime..
-
(I copied interrupt setup from another script, dont know if its 100% correct, but it works :P) i think ir runs the timer1 each 1ms.
int min_mem=32000; int free_mem=0; ISR(TIMER1_COMPA_vect) { cli(); extern int __heap_start, *__brkval; int m = (int) &m - (__brkval == 0 ? (int) &__heap_start : (int) __brkval); if (m < min_mem) min_mem=m; free_mem=m; sei(); } int main(void) { init(); cli(); TCCR1A = 0; TCCR1B = 0; TCNT1 = 0; OCR1A = 1000; TCCR1B |= (1 << WGM12); TCCR1B |= (1 << CS11); TIMSK1 |= (1 << OCIE1A); sei(); while (1) { do_stuff(); delay(100); Serial.print("mem: "); Serial.print(free_mem,DEC); Serial.print(" - lowest: "); Serial.println(min_mem,DEC); } }
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login