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.
www.danlhenry.com/.../keil_code.png
Be sure to carefully study all the literature (knowledgebase articles & application notes) about Function pointers in C51...!!
This is not trivial!