Skip to main content

IAR Embedded Workbench for Arm 9.70.x

__ramfunc

In this section:
Syntax

See Syntax for object attributes.

Description

The __ramfunc keyword makes a function execute in RAM. Two code sections will be created: one for the RAM execution (.textrw), and one for the ROM initialization (.textrw_init).

If a function declared __ramfunc tries to access ROM, the compiler will issue an error. This behavior is intended to simplify the creation of upgrade routines, for instance, rewriting parts of flash memory.

Functions declared __ramfunc are by default stored in the section named .textrw.

For functions declared __ramfunc, the initialize manually command in the linker configuration file disables the regular automatic initialize by copy mechanism and calls the __iar_init_ramfunc function instead.

If you do not want to initialize __ramfunc functions, you must replace the __iar_init_ramfunc function with a dummy function, like this:

void * __iar_init_ramfunc(void * tab)
{
    return tab;
}
Example
__ramfunc int FlashPage(char * data, char * page);
See also

Execution in RAM.

To read more about __ramfunc declared functions in relation to breakpoints, see Setting breakpoints in __ramfunc declared functions.