SPRU514Z July 2001 – October 2023 SM320F28335-EP
The following variable attributes are supported:
The aligned attribute used on a variable has the same effect as the DATA_ALIGN pragma. See Section 6.9.5
The blocked and noblocked attributes can be used to control blocking on specific variables, including arrays and structs. See Section 3.11 for reasons to block or unblock variables. These attributes must be used on both the definition and declaration of the variable. It is recommend that these attributes be used in the header file where a variable is declared. For example:
__attribute__((blocked))
extern int my_array[];
__attribute__((noblocked))
extern struct_type my_struct;
The noblocked attribute can also be used to reference data defined in assembly or in a CLA translation unit that is not blocked.
The linker provides a diagnostic message if data access that treats a variable as blocked is attempted on non-blocked data.
The location attribute has the same effect as the LOCATION pragma. See Section 6.9.16. For example:
__attribute__((location(0x100))) extern struct PERIPH peripheral;
If the address specified with the location attribute is in the lower 16 bits of memory, more efficient instructions with fewer DP loads are used.
Alternately, syntax that specifies an address when dereferencing a literal can be used to allow the compiler to select more efficient instructions for handing addresses in the lower 16 bits of memory. For example, either of the following could be used:
#define peripheral (*((struct PERIPH)(0x100)))
struct EPWM_REGS volatile* const epwm1 = (struct EPWM_REGS *)(0x4000);
The noinit and persistent attributes (for EABI only) apply to the ROM initialization model and allow an application to avoid initializing certain global variables during a reset. The alternative RAM initialization model initializes variables only when the image is loaded; no variables are initialized during a reset. See the "RAM Model vs. ROM Model" section and its subsections in the TMS320C28x Assembly Language Tools User's Guide.
The noinit attribute can be
used on uninitialized variables; it prevents those variables from being set to 0
during a reset. The persistent attribute can be used on initialized
variables; it prevents those variables from being initialized during a reset. By
default, variables marked noinit or persistent will be placed in sections named
.TI.noinit
and .TI.persistent
,
respectively. The location of these sections is controlled by the linker command
file. Typically .TI.persistent sections are placed in FRAM for devices that support
FRAM and .TI.noinit sections are placed in RAM. Also see Section 6.9.18.
The preserve and update attributes are used with the Live Firmware Update (LFU) capability, which supports the ability to perform a "warm start" to upgrade firmware without taking a system offline. Both attributes use the symbol address list obtained from the reference ELF image that was specified when the executable was compiled and linked. See Section 2.15 for more about LFU, which is supported for EABI only.
.TI.bound
section. If the .TI.bound sections are contiguous in memory, the linker can
coalesce them into a single output section, which reduces the number of CINIT
records required to initialize them. The following examples use the preserve
attribute:int __attribute__((preserve)) gvar_bss_preserve;
int __attribute__((preserve)) gvar_0 = 0x30;
static int __attribute__((preserve)) svar_0 = 0x50;
.TI.update
output section. This section defaults to copy
compression (that is, no decompression is required during a warm start), which
reduces the LFU image switchover time. The following examples use the update
attribute:int __attribute__((update)) gvar_bss_update;
int __attribute__((update)) gvar_1 = 0x50;
static int __attribute__((update)) svar_1 = 0x70;
The retain attribute has the same effect as the RETAIN pragma (Section 6.9.22). That is, the section that contains the variable will not be omitted from conditionally linked output even if it is not referenced elsewhere in the application.
The section attribute when used on a variable has the same effect as the DATA_SECTION pragma. See Section 6.9.6
The used attribute is defined in GCC 4.2 (see http://gcc.gnu.org/onlinedocs/gcc-4.2.4/gcc/Variable-Attributes.html#Variable-Attributes).
The weak attribute has the same effect as the WEAK pragma (Section 6.9.25).