Yahoo Groups archive

Lpc2000

Index last updated: 2026-04-28 23:31 UTC

Message

Re: Flash Versus RAM

2005-11-14 by Karl Olsen

--- In lpc2000@yahoogroups.com, "Ake Hedman, eurosource" <akhe@b...> 
wrote:
>
>> Sometimes you want some functions in RAM.  Those functions count
>> as initialized global/static variables.
> 
> How do one make a function go into ram?

With gcc, the easiest way is like this:

static void ramfunc (int i) __attribute__ ((section(".data")));
static void ramfunc (int i)
{
  /* ... */
}

This means that the compiler puts the function in section .data 
instead of .text, and the linker and startup code then locates and 
processes it like initialized data, i.e. stores an initial copy in 
flash, and lets the startup code copy it to RAM.  The final RAM 
address is then used when you reference the function.

Note that flash and RAM functions cannot call each other directly 
since flash and RAM are more than 32 MB apart in the memory map, out 
of reach by the BL instruction.  You then have to use indirect calls 
through function pointers.

Karl Olsen

Attachments

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.