Keil can't access memory from READWRITE section

I am a beginner now learning to program assembly code using keil uvision 5.41. I am running a basic program.
Below is my code. When I build the target and run it in debugger. It shows that my R0 have a value of 0x20000000. But it just doesn't load the values from MyData to R1, R2 and so on.

    AREA MyData, DATA, READWRITE
numbers
    DCD 0x1111, 0x2222, 0x3333

    AREA mycode, CODE, READONLY
    ENTRY
    EXPORT __main
__main
    LDR R0, =numbers
    LDR R1, [R0]
    LDR R2, [R0, #4]
    END

I have checked my read/write memory access, which is located at 0x200000 default location, with No Init box checked. I also unchecked my "Use memory layout from target dialog".

below is the contents of my scatter file
LR_IROM1 0x08000000 0x00080000 { ; load region size_region
  ER_IROM1 0x08000000 0x00080000 { ; load address = execution address
    *.o (RESET, +First)
    *(InRoot$$Sections)
    .ANY (+RO)
    .ANY (+XO)
}
RW_IRAM1 0x20000000 UNINIT 0x00020000 { ; RW data
    .ANY (+RW +ZI)
    *(MyData)
    }
}

Need help from the community to help figure out my problem. Thanks in advance

Parents
  • Main problem is, that your code overwrites the "__main" function. In the Arm Runtime Library, __main is the entry point for the startup code, that also does the RW data initialization. I suggest, you use "main" instead of "__main" in your code to let the standard startup code run.

    Other potential problem could be, that with this:

    RW_IRAM1 0x20000000 UNINIT 0x00020000 { ; RW data
        .ANY (+RW +ZI)
        *(MyData)
        }
    }

    there is always the chance, other RW data in the projects gets placed before your data.

Reply
  • Main problem is, that your code overwrites the "__main" function. In the Arm Runtime Library, __main is the entry point for the startup code, that also does the RW data initialization. I suggest, you use "main" instead of "__main" in your code to let the standard startup code run.

    Other potential problem could be, that with this:

    RW_IRAM1 0x20000000 UNINIT 0x00020000 { ; RW data
        .ANY (+RW +ZI)
        *(MyData)
        }
    }

    there is always the chance, other RW data in the projects gets placed before your data.

Children
No data