What fills up the RAM in MCU

Discussion in 'Embedded Systems and Microcontrollers' started by aamirali, Jul 15, 2014.

  1. aamirali

    Thread Starter Member

    Feb 2, 2012
    415
    1
    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?
     
  2. shteii01

    AAC Fanatic!

    Feb 19, 2010
    3,395
    497
    Is there chip simulator in MPLab? If you simulate the chip, would MPLab show the contents of various memories and registers?
     
  3. THE_RB

    AAC Fanatic!

    Feb 11, 2008
    5,435
    1,305
    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.
     
  4. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,394
    1,606
    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.
     
Loading...