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'm working with some project right now, I need some example about how to run part of code from RAM. I found the code in IAR version, I wonder if someone can help me to translate it into KeilC version.
void runFunctionFromRam(void (*func) (void), unsigned char *ramPtn, unsigned char length) { unsigned char code *codePtn; unsigned char i; // void *f (void * ptr);
// Save start address for function in RAM void *f (void) = (void*)(int)ramPtn;
// get pointer to function in code codePtn = (unsigned char code *)(int)func;
// Copy function from code to RAM for(i = 0; i < length; i++) { ramPtn[i] = codePtn[i]; } EA = 0;
// Enable unified code model MEMCTR |= 0x40;
// Run function from RAM
// Disable unified code model MEMCTR &= ~0x40; EA = 1; }
I'm having problem with these line : void *f (void) = (void*)(int)ramPtn; and (*f)(void);
The compiler won't let me pass with these line.
I need some example about how to run part of code from RAM.
What chip are you using ? It needs to deviate quite a bit from a "standard" '51 to able to run code from some type of RAM - in a normal '51 code memory consists of (EEP)ROM.
The 8051 itself knows nothing at all about RAM or (EEP)ROM - all it knows is its address spaces - CODE, XDATA, etc.
The 8051 architecture has no capability to fetch instructions from any address space other than CODE - it neither knows nor cares whether that address space is populated with RAM, ROM, FRAM, Magnetic Core, or anything else...
See my post "RE: Common over-simplification" here: http://www.keil.com/forum/docs/thread10818.asp
And the linked "8051/8052 Memory Architecture" in this thread: http://www.keil.com/forum/docs/thread10634.asp