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.