What fills up the RAM in MCU

Thread Starter

aamirali

Joined Feb 2, 2012
412
I am using PIC12F675 in my code & MPLAB with Hitech C.

In my entire code I am using 7 bytes varaibles as global, rest all are local.
But my data space is 32 bytes after I build the code finally.

1. So what is filling up the RAM?
2. How to know what is the stack size gone?
 

shteii01

Joined Feb 19, 2010
4,644
Is there chip simulator in MPLab? If you simulate the chip, would MPLab show the contents of various memories and registers?
 

THE_RB

Joined Feb 11, 2008
5,438
I am using PIC12F675 in my code & MPLAB with Hitech C.

In my entire code I am using 7 bytes varaibles as global, rest all are local.
But my data space is 32 bytes after I build the code finally.

1. So what is filling up the RAM?
2. How to know what is the stack size gone?
It's probably allocating a RAM space for every variable, even though some are local.

Compilers for microcontrollers don't normally use dynamic runtime allocation for RAM. If you make a variable anywhere, it uses up RAM, unless the compiler sees that variable is never used.

Doesn't your compiler have a drop down window to show all the RAM allocation? You should be able to see the name of every var and where the compiler have placed it in RAM.
 

ErnieM

Joined Apr 24, 2011
8,377
C operators and functions themselves need memory. Even something as simple as:

a = b + c;

will need some memory to hold the intermediate values, or the place to hold the sum until (b + c) is coppied into a.

Your compiler thus reserves a few bytes for it's own internal uses.
 
Thread starter Similar threads Forum Replies Date
JohnInTX General Electronics Chat 2
loosewire Off-Topic 36
Top