RAM memory usage

Go To Last Post
5 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I have an ATmega328P, which has 2Kb RAM memory.

My current program seems to be at the very limit of the RAM memory; I see that by just declaring one buffer a bit longer, then the program has a strange behavior. (this buffer is actually not used).

What is the best way to debug (keep track of) the RAM memory usage?

Many thanks,
David

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Search the forum for "stack" and "painting". I believe there was such a thread. If that does not help, then search without "painting". There have been many threads related to that.

If you do not have recursions, function pointers, do not use avr-libc much, do not do anything fancy in interrupts, etc, then you can try my ezstack utility. Just "ezstack file.elf". If it likes your elf and does not give you any errors, then it should give you the total RAM usage, including stack. You can get the utility from http://home.comcast.net/~ezstack/

Eugene

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Look at the generated linker map.
Or just look at your source code. Two kilobytes isn't a lot of memory to keep track of; you probably didn't declare a thousand separate static variables, did you? Most applications would have declared a much smaller number of variables, with the remaining space being devoted to a few moderate-to-large arrays. After you've counted up all the variables you explicitly created, how does the total size compare against the known limit of 2K?

If the two figures are miles apart, the likeliest culprit is string variables, as in:

const char *syntaxComplaint = "Could not parse input line\n";

. If that's your trouble, look into having such strings kept exclusively in FLASH.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

After compiling, what % of ram usage is given ?

1) Studio 4.18 build 716 (SP3)
2) WinAvr 20100110
3) PN, all on Doze XP... For Now
A) Avr Dragon ver. 1
B) Avr MKII ISP, 2009 model
C) MKII JTAGICE ver. 1

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

As no one else has mentioned it: PROGMEM

(which is what Levenkay was alluding to)