12.4 Using More than 32K of Constants
By default, the compiler collects const-qualified variables and string
literals into a compiler managed section named .const
. This section is
allocated in program memory, and is mapped into data memory by means of the Program Space
Visibility (PSV) window, or the Extended Data Space (EDS) window. Variables may be
explicitly assigned to this section with the space(auto_psv)
attribute.
Because .const
is a PSV-type section, it is limited to
32K of total constants. To use more constants, variables may be assigned to other sections
with the space(psv)
attribute. This attribute causes the variable to be
allocated in a program memory section that is designated for use with the PSV or EDS
window.
For example:
const int __attribute__((space(psv))) table1[] =
{ 1, 2, 3, /* and so on */ };
space(psv)
specifies the allocation of the variable, but
it does not describe how the variable will be accessed. In order to access variables in
space(psv)
, the PSV or EDS page register must be managed so that the
correct range of program memory is visible. Two options for managing the page register are
available: compiler-managed access, or user-managed access.