SLAU646F September 2015 – June 2020
The following attributes may be applied to function declarations:
Disable interrupts on entry, and restore the previous interrupt state on exit.
Make the function an interrupt service routine for interrupt "x". This attribute can also be used without an argument. If no argument is used, the function is not linked to an interrupt, but the function will have properties that are associated with interrupts.
To define an interrupt, use the following syntax:
void __attribute__ ((interrupt(INTERRUPT_VECTOR))) INTERRUPT_ISR (void)
Example:
void __attribute__ ((interrupt(UNMI_VECTOR))) UNMI_ISR (void)
{ // isr }
You can also use the
following macro defined in the iomacros.h
file, which is
automatically included when using msp430.h
from the MSP430
GCC support
files:
#define __interrupt_vec(vec)__attribute__((interrupt(vec)))
Example:
void __interrupt_vec(UNMI_VECTOR) UNMI_ISR (void)
{}
Can be applied to declarations of functions or static/global data. It instructs the linker to place the section containing the function or data object at the specified address if possible.
For accurate placement, objects with this location attribute should be in
their own sections. This can be achieved by using the GCC command-line
options -f{function,data}-sections
or by applying the
"section" attribute to the object’s declaration.
The memory region containing the specified address must be compatible with the type of section created for the object. For example, you cannot place read/write data in a read-only memory region. The linker deduces the memory region type from the flags set in the linker script for the memory region and the names of output sections that have been placed in that memory region. For example, if a memory region contains an output section called “.text”, the linker assumes that entire region is executable.
The linker renames sections containing objects that use the “location” attribute, giving them the prefix “.smi.location”. These “.smi.location” sections are placed either in their own output sections in the linked executable or within other output sections, among input sections that do not rely on a specific ordering. More specifically, the linker places “.smi.location” sections with other input sections only under certain known output sections such as “.text” or “.data.*”. This prevents “.smi.location” sections from being placed with sections such as “.crt_*”, which rely on section ordering for proper operation of the program.
If the linker cannot place a “.smi.location” section within an output section due to an incompatibility, it places the “.smi.location” section in its own output section at the specified address. It then shifts the incompatible output section to be placed immediately after it.
The linker only attempts to place the first object with a location attribute in an input section. It emits a warning if any subsequent location attributes are ignored. Since the linker can only place location objects at a specific address by placing their input section at that address, it is not possible to accurately place more than one location object per input section.
To initialize data/bss variables that have been placed at specific locations, the linker creates a “.smi.location_init_array” section. The C Run-time (CRT) startup code uses this table to copy data or zero-initialize bss variables just before calling main().
Do not generate a prologue or epilogue for the function.
Disable interrupts on entry, and always enable them on exit.
Can be applied to declarations of functions or static/global data. It instructs the linker to retain the section that contains this object in the linked executable file, even if symbols in that section appear unused. This prevents the section from being garbage collected. This attribute implies that the “used” attribute also applies.
When applied to an interrupt service routine, wake the processor from any low-power state as the routine exits. When applied to other routines, this attribute is silently ignored.