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

Run a code from RAM

I have 32k code and xdata - 32KB size in my design.
If i want to place a C function into RAM and execute from the RAM how should i do it?what are all the settings i need to do? whether can it be done?

For example if we call function2 from function1, can this function1 be placed inside the RAM?

Will there be any errors?

Parents
  • "whether the code memory is RAM or ROM is fairly irrelevant."

    The 8051 knows nothing about RAM or ROM - all it knows is that it has a CODE address space, and an XDATA address space.

    Instructions can be executed from CODE space;
    Instruction can not be executed from XDATA space.

    There is no 8051 instruction to write to CODE space.

    These are fundamental features of the 8051 architecture - there is nothing that you can do about them.
    See the so-called "bible" for the 8051.

    However, what you can do is to design you external memory interface such that the physical memory can be switched between CODE and XDATA space - or even appear in both simultaneously.

    Links for the so-called "bible" for the 8051:

    Chapter 1 - 80C51 Family Architecture:
    www.nxp.com/.../80C51_FAM_ARCH_1.pdf

    Chapter 2 - 80C51 Family Programmer's Guide and Instruction Set:
    www.nxp.com/.../80C51_FAM_PROG_GUIDE_1.pdf

    Chapter 3 - 80C51 Family Hardware Description:
    www.nxp.com/.../80C51_FAM_HARDWARE_1.pdf

Reply
  • "whether the code memory is RAM or ROM is fairly irrelevant."

    The 8051 knows nothing about RAM or ROM - all it knows is that it has a CODE address space, and an XDATA address space.

    Instructions can be executed from CODE space;
    Instruction can not be executed from XDATA space.

    There is no 8051 instruction to write to CODE space.

    These are fundamental features of the 8051 architecture - there is nothing that you can do about them.
    See the so-called "bible" for the 8051.

    However, what you can do is to design you external memory interface such that the physical memory can be switched between CODE and XDATA space - or even appear in both simultaneously.

    Links for the so-called "bible" for the 8051:

    Chapter 1 - 80C51 Family Architecture:
    www.nxp.com/.../80C51_FAM_ARCH_1.pdf

    Chapter 2 - 80C51 Family Programmer's Guide and Instruction Set:
    www.nxp.com/.../80C51_FAM_PROG_GUIDE_1.pdf

    Chapter 3 - 80C51 Family Hardware Description:
    www.nxp.com/.../80C51_FAM_HARDWARE_1.pdf

Children
No data