mcu- ram & rom

Discussion in 'General Electronics Chat' started by aamirali, Jun 19, 2012.

  1. aamirali

    Thread Starter Member

    Feb 2, 2012
    WHen we burn hex file in program, what happened to memory. Like for particular code- hex ile is generated with ram used=200 bytes & rom used = 14 Kbytes
    1. Like hex file which is burned went in rom as it contain our code.
    2. What exactly ram have- initial variables, what else.
    3. Stack is executed during run time. Only its starting address is defined in MCU
  2. MrChips


    Oct 2, 2009
    When you program the MCU the program code goes into ROM, usually FLASH memory.
    RAM is not initialized. It will contain random garbage.

    Program variables in RAM are initialized only when the STARTUP code that has been appended by the compiler gets executed.

    The STACK POINTER gets initialized. The contents of the STACK will contain random garbage.
  3. Markd77

    Senior Member

    Sep 7, 2009
    Agreed. Always initialise variables, in assembler it's often easier to do it in a loop using indirect addressing. Possibly higher level languages may do this for you, but check to make sure. It can be a situation where the simulator differs from reality, Microchip's simulator assumes all RAM is 0 at startup, I looked at the RAM of a PIC16F819 and most of it is filled with 0xFF, with around 10% of the locations having one or more bit cleared.