Syntax Follows the generic syntax rules for object attributes, see Object attributes.
Description The __ramfunc keyword makes a function execute in RAM. Two code segments will be created: one for the RAM execution, and one for the ROM initialization.
If a function declared __ramfunc tries to access ROM, the compiler will issue a warning. This behavior is intended to simplify the creation of upgrade routines, for instance, rewriting parts of flash memory. If this is not why you have declared the function __ramfunc, you may safely ignore or disable these warnings.
Functions declared __ramfunc are by default stored in the segment named CODE_I.
Example __ramfunc int FlashPage(char * data, char * page); See also To read more about __ramfunc declared functions in relation to breakpoints, see the ARM® IAR Embedd __ram: RAM Function The CARM Compiler supports RAM functions which are copied to RAM for execution. The __ram function attribute defines RAM functions.
The CARM Compiler supports RAM functions which are copied to RAM for execution. The __ram function attribute defines RAM functions.
« type » funcname (« args ») __ram Where
type is the type of the value returned from the function. If no type is specified, int is assumed. funcname is the name of the function. args is the argument list for the function. __ram indicates that the function should be copied to RAM before execution.
For example:
#define M16(adr) (*((volatile unsigned short *) (adr)))
void my_prog_func (unsigned short val, unsigned short *adr) __ram { M16(base_adr + 0xAAA) = 0xAA; // enter programming mode M16(base_adr + 0x554) = 0x55; M16(base_adr + 0xAAA) = 0xA0; M16(adr) = val; // program value while (M16(adr) != val); // wait until programmed }