IT lexicon › Programming › RAM function

RAM function

Programming På svenska → Updated: 2026-11-04

A firmware function linked to run from RAM instead of flash, either because it must execute while the flash is busy or because it has to be fast.

The usual reason is that many microcontrollers cannot read from a flash bank while that same bank is being erased or programmed. Code that writes flash — a bootloader's update routine, EEPROM emulation — has to live elsewhere. The other reason is speed: flash needs wait states at higher clock rates, SRAM does not, and a timing-critical interrupt handler becomes both quicker and more predictable.

The function is tagged with an attribute — __RAMFUNC, a .ramfunc section, ESP-IDF's IRAM_ATTR — and the linker script stores it in flash but links it against a RAM address. Startup code then copies it across, just like initialised variables. Forget that every helper it calls must also be in RAM and the resulting bug will be rare and baffling.

← Back to the lexicon