Keil Logo

C251: COPYING FUNCTIONS TO RAM FOR EXECUTION


Information in this article applies to:

  • C251 Version 2.14

QUESTION

I wish to copy some C functions to RAM from Flash memory so they can be executed there while I erase my Flash. How can this be achieved? Reassigning a function pointer does not work.

ANSWER

The only way to achieve this is with the following steps:

  1. Place your C functions to be copied into a seperate source file and add
    #pragma SRC
    
  2. Compile to generate the optimized assembly code for the C functions.
  3. Edit the assembly code so the functions are completely relocatable. Absolute addresses must NOT be used.
  4. Write a custom copying routine to copy the assembly functions from Flash to RAM.

Reassigning a function pointer will simply make the pointer point to a new area of memory. The function will not be copied.

MORE INFORMATION

  • Refer to SRC in the Cx51 User's Guide.

Last Reviewed: Friday, July 15, 2005


Did this article provide the answer you needed?
 
Yes
No
Not Sure
 
  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.