This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

When using MDK, data in Area Data cannot be initialized,why?

I am using LPC2138. I write a simple assembler program and I find the data defined in data area cannot be initialized. the following is my code. I find the TEST is placed on the address 0x40000000, but when I watch the address, the data on the address is not 100 which i have wished. why? please help me.

        AREA TESTCODE,CODE,READONLY
        CODE32
        ENTRY
        EXPORT  START
START
        LDR     R0,=TEST
        LDR     R1,[R0]

        LDR     R0,=START
        BX      R0

        AREA TESTDATA,DATA,READWRITE
TEST DCB 100

        END

  • Who or what do you expect will initialize the RAM?

    The loader when you download your application?
    The processor itself after a reset?

    Note that the RAM region is volatile, so everytime you power up your processor, someone must take care of initializing all variables.

    When writing in C, the compiler/linker includes a helper function that will zero-fill uninitialized variables and unused RAM and will copy the initial state for initialized variables from a region in flash.