Hi Michael,
Your method will give you a rough idea of how much memory your program will use - assuming whatever compiler you're using doesn't automatically optimize variables straight into the AVR registers. But keep in mind that calling routines and/or passing parameters can eat away at memory too, because of stack usage. Be careful, though, with your data types - different compilers might allocate a different number of bytes for a particular data type - an 'int' in one might not be the same size as an 'int' in another. Depends which particular standard - if any - the compiler or language uses. You'll need to check the compiler documentation, to be certain. One other thing, the addition won't be accurate if the arrays are transient (i.e. due to scope).
It might be possible for you to get an idea about what's happening with your program and memory usage simply by running it in the AVR Studio Simulator (free download from Atmel / AVRfreaks). Or, you could check out the avr-gcc documentation and forum (if that's the compiler you're using) - again, on (or links from) the AVRfreaks site.
Regards,
-Pete.
--
http://home.comcast.net/~pete.gray/
"Michael Dombrowski" wrote in message
news:2ljtl2FdegmmU1@uni-berlin.de...
> Hello All,
> I've design my app on a 8515 for ease of debugging and prototyping,
> although in terms of code space and pin usage it should fit onto a 2313.
> My question though concerns memory usage. In the program I declare an
> int array 40 elements, an int array of 79 elements, and 11 other int
> variables giving a count of 130bytes of memory used. (I assume I can
> simply add it up like this, or am I missing something with regard to my
> arrarys, +1byte per array maybe?) Since several of these variables are
> being used to store boolean values, I can mesh several of them into one
> char and save a couple of bytes of memory. Now my real question is, is
> simply counting the bytes like this enough to ensure that my program
> will fit into memory? I also have two interrupts and several loops, do
> they use up memory (avr-gcc)? Could I do something like assign all the
> int varibles to registers and just keep the arrays in memory?
>
> Thanks
> Mike