Variables in Program Memory

This feature allows the programmer full flexibility in deciding the placement of variables in memory. Variables can be now declared as part of the program memory, using a very simple and intuitive syntax. For example:

__pmem int c; // 'c' is an integer that will be stored in program memory.

This feature is very useful when data memory is tight, because some or all of the data can be moved to program memory. It can be handled exactly the same way as normal data. This is almost completely transparent to the programmer, with a few exceptions that will be presented in the next paragraphs.

The CPU architecture only allows post increment addressing of words (16-bit data) in program memory. While the compiler circumvents this restriction and allows full access to all data types in program memory, the performance is decreased. If placement of some variables in program memory is needed, and at the same time the execution speed is important, here are some pointers that can be used to organize the code:

This topic contains the following sub-topics: