Hi,
i am using keil ide and controller LPC1837. i want to execute the function which is using IAP commands from RAM.
I found options are available to make that executable code in RAM in following link.
http://www.keil.com/support/docs/3228.htm
I followed the steps given in above link, but i don't find the code gets stored in RAM memory area i have given.
In alternate method, i tried to copy a functions to RAM area using memcpy(). After doing, i was able to see that my code (function) was copied in the RAM area i passed in memcpy. Now i need to execute that functions in RAM.
How to do that. Can anyone help me on this.
Use a function pointer
unsigned char *Buffer = (unsigned char *)0x20002000; // RAM address (you pick/allocate) EVEN alignment typedef void (*pFunction)(void); Func = (pFunction)&Buffer[1]; // ODD (+1) for Thumb code Func();
Thanks Pier,
As you suggested i tried. But i have doubt, how the function definition of Func() can be assigned to RAM address.
typedef void (*pFunction)(void);
pFunction pF1 = Func;
/* definition of Func() */
void Func(void) {
} here the address of Func can be assigned to function pointer pFunction. But adding this line "Func = (pFunction)&Buffer[1];" is giving error saying redefinition of function Func.
How can i assign the RAM address (referred by Buffer) to the function defined Func()
Then don't use the same names. Use the memory method, or have the linker place the function in RAM in the first place.