How to place a function in RAM

From SEGGER - Support Wiki
Jump to: navigation, search


For some situations it may be beneficial or even necessary to place a function in RAM instead of flash. This for example is needed in case a bootloader (that runs from flash) shall update a firmware (running from the same flash but different sectors). As the flash is not accessible for read accesses while it is programmed, the flash programming routines itself need to run from RAM.

In order to put a function into RAM, it needs to be placed into the .fast section. This is done as follows:

__attribute__ ((section(".fast")))  // Place the following function in RAM
void _Delay(void) {
  [...]
}