At 15:31 23-03-05 -0500, you wrote:
> Hi all, I want to reprogram my F1612 in the field via RS232. To
>be able to use block writing, I must run my reprogramming code from RAM and
>I wonder how I can transfer a function (already in flash) there. I must
>know the code start and stop address to copy the entire code in RAM and
>then change the PC register to start reprogramming. I would like to do this
>in C if itÂ’s possible. Thanks, Fred
I think something like (be sure to check the syntax, I'm typing this from
memory!):
unsigned char *rampointer;
void prog_function()
{
...function...
}
void next_to_prog_function()
{
//dummy function
}
memcpy(rampointer, progfunction, next_to_prog_function-prog_function);
(void*())(rampointer)(); //execute function from ram
Rampointer is the pointer to the memory area (make sure you initialize
this). prog_function is the function you want to copy to ram.
next_to_prog_function is a dummy function which identifies the end of
prog_function. Don't forget function names are pointers to their function
in C.
You should also consider what to do when programming is finished. Probably
a call to the reset vector. It is a good idea to make a function which
blinks an LED and runs this from RAM first.
Nico Coesel