Saving SRAM
Even more precious than the scarce program memory in the Arduino is the amount of available SRAM. Recall from Chapter 3 that the ATmega328 has a mere 2,048 bytes of SRAM. That's not megabytes or gigabytes. The ATmega2560 has 8,192 bytes of SRAM—more, but only when compared with the little one.
SRAM is mostly thought of as being used for temporary data storage, such as variables and the like. SRAM is also used for the system stack, the place where return addresses are stored during subroutine calls and interrupts. The stack is also used in interrupt handlers to preserve the contents of the registers needed by the handler itself, so that no registers are harmed in the handling of this interrupt.
Like any precious commodity, SRAM is ...
Get Arduino Internals now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.