We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
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?
I have 32k code and xdata - 32KB size in my design.
What memory types are these ? Is the code memory some type of (flash) ROM and the xdata some type of RAM ?
If i want to place a C function into RAM and execute from the RAM how should i do it?
The '51 can only execute code that is in code memory (unless you roll your own command interpreter). Whether the code memory is RAM or ROM is fairly irrelevant. Note that the '51 cannot write to code memory space (because it is assumed to be some type of ROM).
"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